peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.48k stars 1.43k forks source link

Error: Could not connect to peer #576

Closed neumartin closed 5 years ago

neumartin commented 5 years ago

Hi,

I try to connect two Chrome browsers inside my local LAN, but Im getting this error: peerjs.min.js:13 ERROR PeerJS: Error: Could not connect to peer 7c484....

The RTCSessionDescription content are this (even in other LAN pc, no my localhost):

sdp: "v=0 ↵o=- 7343060410896376962 2 IN IP4 127.0.0.1 ↵s=- ↵t=0 0 ↵a=group:BUNDLE 0 1 ↵a=msid-semantic: WMS JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ↵m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126 ↵c=IN IP4 0.0.0.0 ↵a=rtcp:9 IN IP4 0.0.0.0 ↵a=ice-ufrag:dgRx ↵a=ice-pwd:aVM5LvFRKA5c7Y5jVTxg5chp ↵a=ice-options:trickle ↵a=fingerprint:sha-256 FF:A3:01:78:DA:5C:C0:A4:5F:54:6E:C9:33:1C:43:00:AD:A5:52:31:7A:BF:D0:91:50:08:0F:19:DE:1B:5D:DE ↵a=setup:actpass ↵a=mid:0 ↵a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level ↵a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 ↵a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid ↵a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id ↵a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id ↵a=sendrecv ↵a=msid:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ce9376ee-08cf-4dbe-a712-c825cc7797b9 ↵a=rtcp-mux ↵a=rtpmap:111 opus/48000/2 ↵a=rtcp-fb:111 transport-cc ↵a=fmtp:111 minptime=10;useinbandfec=1 ↵a=rtpmap:103 ISAC/16000 ↵a=rtpmap:104 ISAC/32000 ↵a=rtpmap:9 G722/8000 ↵a=rtpmap:0 PCMU/8000 ↵a=rtpmap:8 PCMA/8000 ↵a=rtpmap:106 CN/32000 ↵a=rtpmap:105 CN/16000 ↵a=rtpmap:13 CN/8000 ↵a=rtpmap:110 telephone-event/48000 ↵a=rtpmap:112 telephone-event/32000 ↵a=rtpmap:113 telephone-event/16000 ↵a=rtpmap:126 telephone-event/8000 ↵a=ssrc:460603779 cname:PSmenTdpoTmfAxcZ ↵a=ssrc:460603779 msid:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ce9376ee-08cf-4dbe-a712-c825cc7797b9 ↵a=ssrc:460603779 mslabel:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ↵a=ssrc:460603779 label:ce9376ee-08cf-4dbe-a712-c825cc7797b9 ↵m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 ↵c=IN IP4 0.0.0.0 ↵a=rtcp:9 IN IP4 0.0.0.0 ↵a=ice-ufrag:dgRx ↵a=ice-pwd:aVM5LvFRKA5c7Y5jVTxg5chp ↵a=ice-options:trickle ↵a=fingerprint:sha-256 FF:A3:01:78:DA:5C:C0:A4:5F:54:6E:C9:33:1C:43:00:AD:A5:52:31:7A:BF:D0:91:50:08:0F:19:DE:1B:5D:DE ↵a=setup:actpass ↵a=mid:1 ↵a=extmap:14 urn:ietf:params:rtp-hdrext:toffset ↵a=extmap:13 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time ↵a=extmap:12 urn:3gpp:video-orientation ↵a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 ↵a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay ↵a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type ↵a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing ↵a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07 ↵a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space ↵a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid ↵a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id ↵a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id ↵a=sendrecv ↵a=msid:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP 2aab2f53-cefe-4a50-a61b-39ed0b3b6b67 ↵a=rtcp-mux ↵a=rtcp-rsize ↵a=rtpmap:96 VP8/90000 ↵a=rtcp-fb:96 goog-remb ↵a=rtcp-fb:96 transport-cc ↵a=rtcp-fb:96 ccm fir ↵a=rtcp-fb:96 nack ↵a=rtcp-fb:96 nack pli ↵a=rtpmap:97 rtx/90000 ↵a=fmtp:97 apt=96 ↵a=rtpmap:98 VP9/90000 ↵a=rtcp-fb:98 goog-remb ↵a=rtcp-fb:98 transport-cc ↵a=rtcp-fb:98 ccm fir ↵a=rtcp-fb:98 nack ↵a=rtcp-fb:98 nack pli ↵a=fmtp:98 profile-id=0 ↵a=rtpmap:99 rtx/90000 ↵a=fmtp:99 apt=98 ↵a=rtpmap:100 VP9/90000 ↵a=rtcp-fb:100 goog-remb ↵a=rtcp-fb:100 transport-cc ↵a=rtcp-fb:100 ccm fir ↵a=rtcp-fb:100 nack ↵a=rtcp-fb:100 nack pli ↵a=fmtp:100 profile-id=2 ↵a=rtpmap:101 rtx/90000 ↵a=fmtp:101 apt=100 ↵a=rtpmap:102 H264/90000 ↵a=rtcp-fb:102 goog-remb ↵a=rtcp-fb:102 transport-cc ↵a=rtcp-fb:102 ccm fir ↵a=rtcp-fb:102 nack ↵a=rtcp-fb:102 nack pli ↵a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f ↵a=rtpmap:122 rtx/90000 ↵a=fmtp:122 apt=102 ↵a=rtpmap:127 H264/90000 ↵a=rtcp-fb:127 goog-remb ↵a=rtcp-fb:127 transport-cc ↵a=rtcp-fb:127 ccm fir ↵a=rtcp-fb:127 nack ↵a=rtcp-fb:127 nack pli ↵a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f ↵a=rtpmap:121 rtx/90000 ↵a=fmtp:121 apt=127 ↵a=rtpmap:125 H264/90000 ↵a=rtcp-fb:125 goog-remb ↵a=rtcp-fb:125 transport-cc ↵a=rtcp-fb:125 ccm fir ↵a=rtcp-fb:125 nack ↵a=rtcp-fb:125 nack pli ↵a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f ↵a=rtpmap:107 rtx/90000 ↵a=fmtp:107 apt=125 ↵a=rtpmap:108 H264/90000 ↵a=rtcp-fb:108 goog-remb ↵a=rtcp-fb:108 transport-cc ↵a=rtcp-fb:108 ccm fir ↵a=rtcp-fb:108 nack ↵a=rtcp-fb:108 nack pli ↵a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f ↵a=rtpmap:109 rtx/90000 ↵a=fmtp:109 apt=108 ↵a=rtpmap:124 red/90000 ↵a=rtpmap:120 rtx/90000 ↵a=fmtp:120 apt=124 ↵a=rtpmap:123 ulpfec/90000 ↵a=ssrc-group:FID 1208933291 3018405241 ↵a=ssrc:1208933291 cname:PSmenTdpoTmfAxcZ ↵a=ssrc:1208933291 msid:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP 2aab2f53-cefe-4a50-a61b-39ed0b3b6b67 ↵a=ssrc:1208933291 mslabel:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ↵a=ssrc:1208933291 label:2aab2f53-cefe-4a50-a61b-39ed0b3b6b67 ↵a=ssrc:3018405241 cname:PSmenTdpoTmfAxcZ ↵a=ssrc:3018405241 msid:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP 2aab2f53-cefe-4a50-a61b-39ed0b3b6b67 ↵a=ssrc:3018405241 mslabel:JFQBYr589n0yuxAGO7vTNDk4TqmmMcy9dfKP ↵a=ssrc:3018405241 label:2aab2f53-cefe-4a50-a61b-39ed0b3b6b67 ↵" type: "offer"

afrokick commented 5 years ago

@neumartin Even in local network the NAT problem may exists.

Which version do you use?

Did you try to use relay server?

const peer = new Peer('randomId', { config: {
  iceServers: [
    { urls: "stun:stun.l.google.com:19302" },
    { urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" }
  ],
  sdpSemantics: "unified-plan",
  iceTransportPolicy: "relay" // <- it means using only relay server (our free turn server in this case)
}});
...
neumartin commented 5 years ago

@afrokick thanks for your answer!! I try in my local network (LAN), but I will try your solution and post heare the results. Thanks!

afrokick commented 5 years ago

@neumartin any news?)

afrokick commented 5 years ago

closed because no activity. Please reopen if issue still exists

ppseprus commented 3 years ago

hey!

I know this has been closed, but Im kind of having a similar issue. I see my peers (both running on my localhost) connect to Peer Server via WS and I do see CANDIATE frames come and go. but no peer connection. I tried to use the above configuration, but even the CANDIDATE frames are gone.

can someone please help? for starters: what should I even paste here?

thanks, Peter

neumartin commented 3 years ago

Hi @ppseprus, I solved my problem using a STUN and TURN server. Google has free stun servers, but turn servers are not free. I installed my own turn server in one ubuntu server using COTURN, you can find more information here:

https://github.com/coturn/coturn

https://ourcodeworld.com/articles/read/1175/how-to-create-and-configure-your-own-stun-turn-server-with-coturn-in-ubuntu-18-04

ppseprus commented 3 years ago

hey @neumartin , thanks for the comment. not long after my comment here, I found this https://github.com/peers/peerjs/issues/652 id pretty much did the trick for and I was bashing head against wall.. :D

charlly-code commented 2 years ago

@neumartin Even in local network the NAT problem may exists.

Which version do you use?

Did you try to use relay server?

const peer = new Peer('randomId', { config: {
  iceServers: [
    { urls: "stun:stun.l.google.com:19302" },
    { urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" }
  ],
  sdpSemantics: "unified-plan",
  iceTransportPolicy: "relay" // <- it means using only relay server (our free turn server in this case)
}});
...

thanks for this... it helped me