simple-peer
simple-peer copied to clipboard
Simple Peer Doesn't work on different network
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.
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
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?
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.