webrtc-rs / turn Goto Github PK
View Code? Open in Web Editor NEWA pure Rust implementation of TURN
Home Page: https://webrtc.rs
License: Apache License 2.0
A pure Rust implementation of TURN
Home Page: https://webrtc.rs
License: Apache License 2.0
Hello
I am trying to get the example turn server working in conjunction with a Rust-WASM binary running in the browser.
I think i have mostly gotten it to work, and accept the credentials i give it.
I tested this with the webrtc trickle page, adding my locally hosted turn server address + valid credentials, and setting the IceTransports
value to relay
, and the turn relay server info did come up.
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
I'm using https://docs.rs/web-sys/latest/web_sys/ for all structs described below.
I am also including a link to the code I am working on at the here
https://github.com/Charles-Schleich/WebRTC-in-Rust/tree/turn_experiments
Note: In the browser I can a create a RtcPeerConnection
on each of two peers if i set RtcIceTransportPolicy::All
and they can setup and connect directly peer to peer between the browsers no problem.
What I am trying now is to force using a relay by setting up the RtcPeerConnection
with a RtcConfiguration
And setting the transport policy to RtcIceTransportPolicy::Relay
My issue is now is that the credentials are accepted, but i just get a tonne of messages relating to
No Permission or Channel exists for turn_ip:portx on allocation turn_ip:porty
[2022-03-01T17:55:36Z INFO turn::allocation] No Permission or Channel exists for 192.168.178.76:58464 on allocation 192.168.178.76:40583
[2022-03-01T17:55:36Z DEBUG turn::server::request] handle_turn_packet
[2022-03-01T17:55:36Z DEBUG turn::server::request] received SendIndication from 192.168.178.76:55031
[2022-03-01T17:55:36Z DEBUG turn::allocation] relay socket Ok(192.168.178.76:30556) received 100 bytes from 192.168.178.76:58464
[2022-03-01T17:55:36Z INFO turn::allocation] No Permission or Channel exists for 192.168.178.76:58464 on allocation 192.168.178.76:30556
[2022-03-01T17:55:36Z DEBUG turn::server::request] handle_turn_packet
[2022-03-01T17:55:36Z DEBUG turn::server::request] received SendIndication from 192.168.178.76:52718
[2022-03-01T17:55:36Z DEBUG turn::allocation] relay socket Ok(192.168.178.76:47986) received 100 bytes from 192.168.178.76:9323
[2022-03-01T17:55:36Z INFO turn::allocation] No Permission or Channel exists for 192.168.178.76:9323 on allocation 192.168.178.76:47986
[2022-03-01T17:55:36Z DEBUG turn::server::request] handle_turn_packet
[2022-03-01T17:55:36Z DEBUG turn::server::request] received SendIndication from 192.168.178.76:47233
[2022-03-01T17:55:36Z DEBUG turn::allocation] relay socket Ok(192.168.178.76:47986) received 100 bytes from 192.168.178.76:7641
[2022-03-01T17:55:36Z INFO turn::allocation] No Permission or Channel exists for 192.168.178.76:7641 on allocation 192.168.178.76:47986
[2022-03-01T17:55:36Z DEBUG turn::server::request] handle_turn_packet
[2022-03-01T17:55:36Z DEBUG turn::server::request] received SendIndication from 192.168.178.76:55847
[2022-03-01T17:55:36Z DEBUG turn::allocation] relay socket Ok(192.168.178.76:6919) received 100 bytes from 192.168.178.76:42724
...
I figured i might need a RelayAddressGeneratorRanges
instead of a single RelayAddressGeneratorStatic
, but that doesn't seem to be the issue.
Am I fundamentally misunderstanding something about the port allocation or how this library is working ?
Is it to do with the net
struct member not having a proper config ?
Or is there another issue with the way that I have set this up ?
Link to the turn server follows.
https://github.com/Charles-Schleich/WebRTC-in-Rust/blob/turn_experiments/turn-server/src/main.rs
Any guidance would be super appreciated.
Thank you in advanced !
use signal_hook::iterator::Signals;
| ^^^^^^^^ could not find iterator
in signal_hook
Hi!
I'm using pion-webrtc for my rtc peer connection with this rust turn
After a few days, i cannot peer because i see the ICE state
never change to connected
.
When i checked rust turn
log, i saw this error
And try to gather candidate via test rtc
At you can see, the relay candidate
is failed.
After i restarted rust-turn
service, everything is ok.
This is my turn config.
Could you guys tell me anything wrong!
Thanks in advance
When creating a server, some implementations provide a method to avoid providing a relay, or otherwise controlling the relay (throttling, killing connections, etc). Is there any way to do this in this package?
Reason I am asking here and not in stun is this has a server, but stun does not - and it appears many implementations just provide the turn server with a switch to turn off the relay capabilities, rather than a separate STUN/TURN impl.
Soundly the turn server received some bytes not conforming the standards, then the process always running CPU in 100%.
The server log is:
listening 0.0.0.0:20011...
Waiting for Ctrl-C...
[2021-04-08T23:13:45Z DEBUG webrtc_turn::server::request] received 407 bytes of udp from 193.107.216.134:5088 on 0.0.0.0:20011
[2021-04-08T23:13:45Z DEBUG webrtc_turn::server::request] handle_turn_packet
[2021-04-08T23:13:45Z ERROR webrtc_turn::server] error when handling datagram: 4f4e5320 is invalid magic cookie (should be 2112a442)
Version: webrtc-turn v0.1.2
A quick test with Firefox and https://jsfiddle.net/9tsx15mg/90/ with the "turn_server_udp" example yields the following error in the example:
ERROR turn::server] error when handling datagram: relay already allocated for 5-TUPLE
"about:webrtc":
STUN-CLIENT(relay(IP4:192.168.0.2:37097/UDP|IP4:192.168.0.2:3478/UDP)::TURN): Received response; processing
STUN-CLIENT(relay(IP4:192.168.0.2:37097/UDP|IP4:192.168.0.2:3478/UDP)::TURN): nr_stun_process_error_response failed
STUN-CLIENT(relay(IP4:192.168.0.2:37097/UDP|IP4:192.168.0.2:3478/UDP)::TURN): Error processing response: Retry may be possible, stun error code 401.
Hello,
I am wondering about the auth_handle
function inside the AuthHandler
trait and whether or not it makes sense to potentially make it an async function using async-trait.
My rational behind wanting this is that if the struct that you implement AuthHandler
for has a RwLock
/ Mutex
it would make more sense to use the RwLock
/ Mutex
that comes from your async framework, rather than std::sync::*
, and it would be more ergonomic to .await
on it rather than spawning a blocking task from a non async function.
If the user wants to add or remove usernames and passwords from elsewhere in the code also within the context of an async function, potentially this turn server is generating or receiving username password combos.
While i have not gone very deep into async Rust, i have read in a couple of places that warn against using std::sync::{RwLock}
in certain scenarios
https://docs.rs/tokio/latest/tokio/sync/struct.Mutex.html#which-kind-of-mutex-should-you-use, but it will also depend on what is being done with the lock.
So if any of the authors of the library feel that it makes sense for auth_handle
to be an async function then i'm happy to implement it and submit a PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.