-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Multiple Relay Sessions Created by Coturn, but Only One Used for Traffic #1647
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
Comments
Hi @eakraly, @jonesmz Could you please take a look at this issue, I am really stuck I can't find a way to solve it. It would be niche if we could find a way to terminate unused sessions as soon as cotrun pickups the "correct" one.. I can try to implement it myself and create PR, but I need to know the place in code where to look at. So the place where coturn decides which session to use for relay communcation. |
Hello |
Hi @dntam00 , yes, I understand that peers take best method, like P2P or Relay. But what I observe: Coturn creates from 4 to 8 sessions .(some for TCP and some for UDP). Later on two of them would be used for Relay Connection. Which we can observe as soon as |
You don't say what software you're using coturn with. coturn is just a proxy. It creates "allocations" (Per the TURN protocol RFC's meaning of the term) when client software asks it to, and then data is relayed through those allocations when the client software sends the data. Coturn has no interest in managing that, it just does what it's told. Typically webrtc clients will create one OR MORE allocations, depending on any number of factors, including TCP vs. UDP, IPv4 vs. IPv6, multiple network connections (Ethernet, wifi, VPN, etc), and so on. But then after those multiple allocations are created, and the initial connection handshake is completed between the two webrtc peers, only one allocation on the turnserver will be used, at most. in most situations with webrtc, even though an allocation is made on the turnserver, it is not used for the media exchange. And even if a turnserver allocation is used to relay traffic, only one such would be used. Almost always this would be the UDP allocation if there are more than one. As for your observation about timeouts. Allocations are kept alive for a config-file determined amount of time, or the amount of time the client asks for, whichever is lower. If your config file says to leave an allocation alive for 10 minutes, then the client software must send refresh packets to keep the allocation alive periodically. If the client software only needs to use one relay, it will typically explicitly shut down the unneeded allocations with a packet saying to refresh the timeout to 0 seconds. But a lot of software is not so polite, and just stops using the no-longer-needed timeout. as far as i can tell, what you're describing in your original comment is the normal and expected behavior. If you have other concerns, please elaborate. |
Hi,
I was trying to separate relay sessions and noticed that when the connection type is "relay," this event is triggered for one of the sessions created by Coturn (Coturn usually creates 4–6 sessions per connection):
However, in some cases, Coturn triggers this event 2 or even 3 times for a single client, leading to the creation of multiple relay sessions. But in the end, only one session is actually used for communication (as observed in traffic logs).
For example, if Coturn creates two relay-sessions for a single client:
I can clearly see that traffic flows only through one session (e.g., 001000000000000002), while the other (001000000000000001) remains unused.
Traffic distribution could look like this:
If the client terminates before the timeout occurs (i.e., in less than 10 minutes), both sessions get terminated, indicating that Coturn is aware of both of them.
However, if the client terminates after the timeout threshold (i.e., more than 10 minutes), the unused session gets terminated first with a "timeout" message after 10 minutes.
reason: allocation timeout
My question:
Thanks in advance for your insights!
The text was updated successfully, but these errors were encountered: