simple-peer: Error: Ice connection failed

Pinned Troubleshooting

This error is caused by a failure to find a viable network route through ICE. The following steps will help you debug common causes of the error.

  1. You have found a bug that is already patched in simple-peer source.
  • Try the latest source code for simple-peer (not the latest npm release).
  1. Your STUN or TURN servers are not configured properly.
  • Ensure you can connect to your STUN/TURN servers with this tool: https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
  • Ensure you receive at least one relay candidate (from the TURN server).
  • Make sure you are using urls and not url in the iceServers config.
  • You specified a config object with no iceServers.
  • Try using your own STUN servers instead of default/public ones (which can be unreliable).
  1. There is a problem with your signalling channel.
  • Ensure latency on signalling messages is not too high (above 10 seconds).
  • Ensure all signal messages are being delivered.
  1. Your firewall or internet provider is blocking WebRTC traffic.
  • Try disabling your firewall first, if it works, test the following:
  • Append “?transport=tcp” to your TURN config to avoid UDP rules.
  • Configure your TURN server to use port 443 to avoid port rules.
  • Use TLS over TCP to avoid packet analysis rules.
  • You WILL NOT need to disable firewalls in production.
  1. You have found a new bug, or a rare case we haven’t discussed here.
  • Opening a NEW issue, mentioning you’ve completed the above steps, and providing a link to a relatively brief and filtered .pcap file is the only way anyone can help you further. https://webrtc.org/testing/wireshark/

Original Issue

Hi, I am trying to make a connection with simple-peer. One side is on node & other side is on chrome. Normally everything is OK. But When one side is switch to phone internet I get “Error: Ice connection failed” error. I have a turn server & using for iceServer config. Any idea how to fix or debug that?

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 58

Most upvoted comments

Hi all In my case one side is on browser and the other side is on nodejs. I have my own turn-stun server installed which is online. l forced simple-peer to work with only relay mode then it works on symmetric-nat. But in this mode l can not work with unsymmetric-nat. I also think this is problem of simple-peer.

I could not find a solution yet.

I can not make the Simple Peer to connect. It shows me the above-mentioned error. Is it because we use Simple-Peer? I suspect, this error was created during the new releases. Moreover, even the Simple-Peer Demo source code cannot work on two different computers from two different networks. I tried all the above suggestions, and absolutely none of them worked for me. I tried dozens of iceServers as well. Any suggestions of how you made it work? You can check my application on my website

The error I receive

Error: Ice connection failed.
    at Peer._onIceStateChange

I can make it only working on localhost (multiple tabs) and in a local network (different computers), but in the same local network. In the local network, I was able to connect between local computers and local browsers from Chrome, Firefox.

The signals look ok for me. Moreover, when the connection is trying to establish, the Ice connection fail error appears on both browsers, so somehow the connection is being initialized, but then it throws the above-mentioned exception.


 { type: 'offer',
     sdp: 'v=0\r\no=- 799787221816349767 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 60755 DTLS/SCTP 5000\r\nc=IN IP4 5.12.206.160\r\na=candidate:2020300070 1 udp 2113937151 192.168.2.8 60755 typ host generation 0 network-cost 50\r\na=candidate:842163049 1 udp 1677729535 5.12.206.160 60755 typ srflx raddr 192.168.2.8 rport 60755 generation 0 network-cost 50\r\na=ice-ufrag:5vLE\r\na=ice-pwd:BZlSkfOQOpzGTamZi1cEWzsR\r\na=fingerprint:sha-256 75:4E:FC:88:55:97:F1:D1:C2:26:88:C3:82:1C:5C:87:DF:DF:C9:90:90:A6:F5:3A:A0:6F:A6:7D:4C:83:B9:77\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n' } }

   { type: 'answer',
     sdp: 'v=0\r\no=- 3314710403443195041 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 63152 DTLS/SCTP 5000\r\nc=IN IP4 86.126.104.54\r\nb=AS:30\r\na=candidate:2702239670 1 udp 2113937151 192.168.1.103 63151 typ host generation 0 network-cost 50\r\na=candidate:842163049 1 udp 1677729535 86.126.104.54 63152 typ srflx raddr 192.168.1.103 rport 63151 generation 0 network-cost 50\r\na=candidate:842163049 1 udp 1677729535 86.126.104.54 63154 typ srflx raddr 192.168.1.103 rport 63151 generation 0 network-cost 50\r\na=candidate:842163049 1 udp 1677729535 86.126.104.54 63153 typ srflx raddr 192.168.1.103 rport 63151 generation 0 network-cost 50\r\na=candidate:842163049 1 udp 1677729535 86.126.104.54 63156 typ srflx raddr 192.168.1.103 rport 63151 generation 0 network-cost 50\r\na=ice-ufrag:3Cvy\r\na=ice-pwd:jS/ZJ29MKW/09l/6SIE6+Nr9\r\na=ice-options:trickle\r\na=fingerprint:sha-256 79:3B:38:E8:90:4F:20:26:C1:8C:9A:2C:00:2E:DC:E9:D6:E1:AA:87:31:01:B8:FD:0B:EE:DD:07:20:B1:D3:73\r\na=setup:active\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n' } }

image

I have been using this library and it’s working fine. As per the WebRTC handshake you need to have TURN not just STUN servers set up and working right.

I am using the turn servers with https://xirsys.com/

var p = new Peer({initiator: location.hash != “#visit”, trickle: false, stream: stream, iceTransportPolicy: ‘relay’, reconnectTimer: 3000, config : { iceServers: JSON.parse(ice_servers)}});

Issues like this really scare away people trying to work with WebRTC. Users should not have to turn off their firewall just to use a service in their browsers.

To all the silly geese who don’t read properly (of which I’m one), make sure you paste the “answer” back into the initiator when running the code from the README.md.

Failing to do this will result in this same error after the timeout.

Here’s the minimal demo I’ve been using to reproduce if anyone is interested in helping with this issue. (You can use https://rabb.it to get a symmetric NAT peer).

https://codepen.io/RationalCoding/pen/bYEmjw?editors=0011