Skip to content
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

XEP-0215: management of the field expires #1510

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mid1221213
Copy link
Contributor

Add a field in Xmpp.Xep.ExternalServiceDiscovery to keep track of the expires TURN service value and use it (divided by 2) to restart periodically the external services discovery.

Without this patch, calls (actually ICE) fail to initiate after 24h of Dino uptime because of the expiry of the TURN credentials.

This happened on my setup using prosody (using the default credentials' TTL of 86400) and coturn.

@mid1221213 mid1221213 mentioned this pull request Jan 10, 2024
@fiaxh
Copy link
Member

fiaxh commented Jan 13, 2024

Thanks for looking into this.

There are some issues:

  • A new Timeout is added whenever a stream is negotiated and they are not cancelled when the stream is broken. That means, there can exist a number of superflurous Timeouts. This is also problematic because the closure captures the stream, preventing it from getting freed.
  • Within the closure, you check whether the account has is connected, but it could be connected via another stream. If the account is connected with a different stream, you would still call the on_stream_negotiated function, but with a broken stream.
  • Please use a DateTime for storing the expired value instead of an int64? - we try to avoid using question-primitives, as accessing them wrongly leads to crashes.
  • Also with those changes, we should rename on_stream_negotiated, since it's not only called on stream negotiation anymore 🙂

Add a field in `Xmpp.Xep.ExternalServiceDiscovery` to keep track
of the `expires` TURN service value and use it (divided by 2) to
restart periodically the external services discovery.
Fix following comment and recommandations:

- Use DateTime? type instead of int64?
- check the computed delay value against sane values
- use a HashMap to keep track of timers and cancel them on connection
  closed
- add equals and hash funcs to XmppStream to use with the HashMap
- rename the callback to reflect its meaning
- test the TURN server conf before STUN default server
@mid1221213
Copy link
Contributor Author

Thanks @fiaxh for your comments. Here is a new version, hopefully better 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants