simple-peer icon indicating copy to clipboard operation
simple-peer copied to clipboard

Simple Peer Doesn't work on different network

Open Nahiduzzaman360 opened this issue 3 years ago • 3 comments

Hey, I have created a simple video chat application using simple peer and webRTC and it's perfectly working on localhost and also in my domain, it's working when my devices are on the same network, but when I try from the different network it's connected but gives an error also don't show the camera stream. I also set up stun and turn server from xirsys.net but the same issue. here is the error:-

simplepeer.min.js:6 Uncaught Error: Connection failed. at p._onConnectionStateChange (simplepeer.min.js:6) at RTCPeerConnection._pc.onconnectionstatechange (simplepeer.min.js:6) _onConnectionStateChange @ simplepeer.min.js:6 _pc.onconnectionstatechange @ simplepeer.min.js:6

and here is my simple peer setup. let peer = new SimplePeer({ initiator, stream: localStream, config: { iceServers: [{urls: [ "stun:hk-turn1.xirsys.com" ]}, {username: "my username", credential: "my credentials", urls: [ "turn:hk-turn1.xirsys.com:80?transport=tcp", "turn:hk-turn1.xirsys.com:3478?transport=tcp", "turns:hk-turn1.xirsys.com:443?transport=tcp", "turns:hk-turn1.xirsys.com:5349?transport=tcp"]}] }, trickle: false });

Please give me a solution, how can I use it from any network.

Nahiduzzaman360 avatar Dec 27 '21 20:12 Nahiduzzaman360

Maybe try a different TURN server. I couldn't ever get the public ones to work until I just started hosting one myself:

https://github.com/zenOSmosis/docker-coturn

jzombie avatar Jan 09 '22 00:01 jzombie

Maybe try a different TURN server. I couldn't ever get the public ones to work until I just started hosting one myself:

https://github.com/zenOSmosis/docker-coturn

Hey, Thanks for your comment, Do you have any idea how can I set up my own turn server in windows?

Nahiduzzaman360 avatar Jan 10 '22 15:01 Nahiduzzaman360

It's set up to use Docker, so it should work in Windows if you have Docker installed.

However, unless your Windows machine is publicly accessible over some IP address / domain, and you have some ports routed to the machine, it won't do any good.

Could try to either host it somewhere on a cheap Linux-based VPS, or could try a different TURN / STUN server altogether.

jzombie avatar Jan 12 '22 14:01 jzombie