I've built a discord-like app where multiple people can join into a channel, talk to each other and also share their screen. It's not peer to peer since there is a Media server which relays all media from one participant to others. In short it's SFU-like approach.
The problem: it doesn't matter whether I'm streaming or just talking with someone, the status of peer connection changes to disconnected
and after 1-2 seconds immediately reconnects back (I have no reconnect logic implemented, it reconnects itself). While being disconnected I obviously can't hear or talk or watch stream (no frames received). Server logs stay clean, no info about disconnections. WebRTC stuff is kinda new thing to me, so for now I have no clue what's happening and I hope to get some advices where to start digging to fix this. I've tried switching TURN server into another (external paid service), disabling TURN and using as STUN-only. Doesn't matter. And TURN server's logs stay clean as well.
This is my setup so far:
Server: Golang, pion/webrtc. The server just relays media data and nothing else.
Client: No webrtc library, all webrtc stuff done using native browser API
Infrastructure: a VPS where client and server run in docker containers being reverse proxied via Nginx. I also have another VPS where a custom TURN server (coturn) is configured as STUN&TURN.
I did finally fix that. The reason was incorrectly configured TURN (coturn) server. I forgot to set realm
field and because of that TURN functionality was not working. I checked that on this site https://icetest.info/. Also not sure if that was important but I uncommented fingerprint
property as well. And finally I moved on to a new VPS via different hosting service with higher bandwidth to make sure the bandwidth will not be bottleneck.