Signalling server on Different network

I am using y-codemirror and y-webrtc for real time collaborative editor. it worked on the devices using same network but didn’t work for the devices for different network using default y-webrtc signalling server.

As far as I understand it, this is a common problem with WebRTC–it works “peer to peer” 90% of the time but there are some network configurations that do not permit peers to talk to each other, even with a STUN (signalling) server facilitating NAT traversal.

In the video conferencing world, they use an additional TURN server to get around this problem for the remaining 10% of network configurations that can’t simply communicate directly (i.e. after STUN fails).

In Yjs land, you could also set up a y-websocket server to facilitate communication in the cases where direct p2p doesn’t work: the server-sent data will consistently converge with the peer-sent data due to the CRDT algorithms backing Yjs types.

Thank you johnson for you reply.

how to implement custom TURN server like twilo, viagence inside yjs for succesful peer connection to use in real time collaboration like in your textarea example.

Help!

I’m afraid I’m not much more help here. I haven’t tried peer-to-peer Yjs yet, and I’m not even sure if a TURN server would work for this purpose. Perhaps others can chime in.

@SagarGi opened several GitHub issues before opening two new threads in the discussion board. He ignored my issue templates and just filled out the headline. I’m not going to reward spamming and banned that person for two weeks.

But since this question is probably relevant to several users and this discussion board is a knowledge base after all …

You can change the signaling server as described in the API docs https://github.com/yjs/y-webrtc#api

The signaling server introduces peers to each other. Even the default public signaling server should work in all networks. I guess that person was actually looking for changing the TURN server (kind of a server that acts as a gateway for two peers when they can’t connect to each other over a direct p2p connection. This often happens when clients are behind firewalls.).

TURN servers are standardized and you can probably use any TURN server project you can find out there. There are some paid services too. y-webrtc uses simple-peer for creating WebRTC connections. simple-peer allows to specify custom TURN servers.

See their documentation ⇒ You can add a Peer configuration using the peerOpts configuration in y-webrtc: https://github.com/yjs/y-webrtc#api