-
Notifications
You must be signed in to change notification settings - Fork 485
Enables ICE-TCP of TURN for WebRTC #1362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- internal fields and properties for turn-tcp state-machine - streamline DateTime epoch specifier IceServer.cs: - internal static properties for turn-tcp state-machine - refactor icerelay property because it's internal-only ** RtpIceChannel.cs **: - refactor descriptions - reduce class constructor overloading by rearranging new useTcp parameter - extract creating new IceTcpReceiver with relay specifier - new logging lines are set as trace-level - fix processchecklist overrun (didn't return after disabling timer) - adds timer skipper on turn-tcp candidate - some TODO suggestions comments - adds turn-tcp state-machine & make the connectivity check block more readable - fixes turn-tcp connection attempt indication and stun binding matching with checklist - extract IP equals function from inside the method - remove TLS placeholder - put TCP reconnection placeholder - *** send TCP by Socket synchronously *** - detached OnPacketReceived to enable internal turn-tcp relay specifier - remove redundant conditional local candidate relay && iceserver null RTPChannel.cs: - reduce class constructor overloading by rearranging new useTcp parameter - adds closereason to receivers closings RTCPeerConnection.cs: - rearrange new useTcp in create RTP channel
4431faf
to
adcdadf
Compare
Hi @sipsorcery , I did a whole PR rebase and merged with v8.0.12 bdbb80f. After reading for quite a while, I'm stuck on the DTLS handshake part. What I found is that the networking part of the library is quite low-level. Once it hits the DTLS handshake as a server, it disconnects the TCP Socket. I'm guessing it has something to do with context switching and threading and the such, it will need more than enough time to figure out what to do, so what I'd like to know is:
That said, both still require a lot of time with the legend Stephen's blog on C# .NET async stuff and sockets. Thanks, |
@ha-ves it takes a bit of mental gymnastics to work out how TCP TURN is meant to work for WebRTC. I think this statement from the Transports for WebRTC best explains it:
So it seems that once the TCP TURN connection is established all packets need to be sent in an RTP packet. This includes the DTLS packets, STUN checks and SCTP (data channel packets). In theory it shouldn't be too difficult to manage the RTP framing given all the packet formats are already supported in this library. I suspect the hardest bit will be managing the TCP connections, particularly edge cases around dropping, re-connecting etc. I always found the TCP/TLS connection management problematic with the SIP transport purely because there is so much more state required to manage timeouts etc. etc. See the SIPTCPChannel class header for lots of gory details. In theory to implement the TCP TURN mechanism what's required is a new implementation of the RTPChannel class that uses a TCP socket instead of the current UDP socket. The RTP framing mechanism could then be completely handled in the RTPTCPChannel. I'd classify it as a medium sized task where the SCTP protocol implementation was a big task (took me 6-7 weeks of full time effort). Apart from that, if it is the case that as you say the support is not yet there in the browsers hard to see it being worth the effort... |
@sipsorcery I see, I think I understand it now. It does seem like there's not quite a way to just replace the network layer if in the end it'll need to be deriving the Thanks, it's really helpful to know what you'd expect. I'll port the current PR and see where it goes from there. As for the browser peer, they don't support it, though RTP middlebox apps usually do support it, and as some people mentioned, their case wants TCP-only connection with the middlebox. And I think especially in industrial areas they only use TCP because they need the connection state. |
@ha-ves Hello, in my project, I want to use TCP for communication between TURN and WebRTC. I noticed that ICE specifies TCP by setting "transport=tcp". I would like to ask what the mechanism of this is? |
That parameter only controls the connection with the relay server, not the resulting ICE candidate.
This PR enables that, but is still stuck on the DTLS part and no direct TCP-TCP yet. ChatGPT:How to use TCP with this library
var pc = new RTCPeerConnection(new()
{
iceServers =
[
new()
{
urls = "turn:turn.example.com:3478?transport=tcp",
username = "user",
credential = "pass",
credentialType = RTCIceCredentialType.password,
X_ICERelayProtocol = RTCIceProtocol.tcp
},
],
iceTransportPolicy = RTCIceTransportPolicy.relay,
//X_ICEForceTCP = true
}); Notes
|
This enables TCP relay communication.
The justification was that the network--even the TURN server network, only allows TCP.
Though, as it currently stands, the RFC is quite new and the browsers don't seem to be implementing it anytime soon, this mode will not support connection with browser-based WebRTC peers.
may close #1294
remaining drafts:
New
public
APIs:X_ICEForceTCP
onRTCConfiguration
ofbool
X_ICERelayProtocol
onRTCIceServer
ofRTCIceProtocol
Dev notes:
IceServer
class additional_secondaryRelayUri
for TURN-TCPrefs: