add STUN/TURN servers after the provider is made
catdevnull opened this issue · 6 comments
services like metered.ca require using an API to get the STUN and TURN servers. the problem is that waiting for the API to respond adds unnecessary latency to syncronizing with other peers which might not need TURN.
being able to add servers after it has been created solves this.
y-webrtc is based on simple-peer. You can add configurations for simple-peer using the peerOpts
configuration. This also allows you to configure STUN and TURN servers.
Changing STUN and TURN servers after the provider has been created doesn't make a lot of sense when a connection has already been established. However, you can change the configuration for all future connections using the provider.peerOpts
property.
yes, i know about peerOpts but i don't want to edit it after the fact precisely for that problem. isn't there any way to update existing connections or force reconnect all non-functioning connections, or at least force reconnect all connections?
WebRTC is such a weird tech that it is even hard to detect broken connections. It's unrealistic that we will be able to switch connection properties after the fact or while connections are establishing. In any case, the payoff is not worth the trouble. If you are worried about the delay because your request is asynchronous, you can preload your connection info.
it's not even necessary to check for broken connections. switching connection properties is most certainty possible through setConfiguration .
If you are worried about the delay because your request is asynchronous, you can preload your connection info.
but if we're offline or in a subway, fetching the API will just take a ton of time and/or timeout. in the subway it doesn't matter because there's no local peers anyway, but things like a dwebcamp or others in which a local network works fine while connection to the internet might be spotty means that the local-first experience is degraded (it won't start connecting to local peers until it timeouts.)
hackily worked around it through https://gitea.nulo.in/Nulo/schreiben/commit/866fbfd7ec2533acc48e642c75ba0fa90694dafb. not ideal, hopefully this issue is reopened so an official API is made.