feross / simple-peer

📡 Simple WebRTC video, voice, and data channels
MIT License
7.41k stars 971 forks source link

Error: Ice connection failed #202

Closed ghost closed 6 years ago

ghost commented 7 years ago

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).
  2. 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).
  3. 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.
  4. 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.
  5. 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.

MiguelRipoll23 commented 5 years ago

My remote connections don’t work, something that I did expect to be honest. I don’t understand why WebRTC doesn’t try to at least open a port on the network to allow communication, this is something that every videogame thst uses voice chat does.

WebRTC is a complex but ineffective protocol.

bparker667 commented 5 years ago

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)}});

tadejrola commented 5 years ago

Worked well on one machine, different browsers, didnt work on same/different network, different machines.

After turning off firewall on both machines, it works. This is not how it is supposed to be done. What else do you recommend? Tried TURN/STUN servers, did not work without turning off firewall.

t-mullen commented 5 years ago

It depends on the configuration of your firewall. You could have set your firewall ruleset to block all traffic completely, or blocked the ports your STUN/TURN servers are on, or blocked UDP traffic. It's impossible to help debug firewall configurations without knowing what they are.

I've pinned my troubleshooting steps to this issue, please follow them and open a new issue with a filtered pcap file if they do not help.

vamshi9666 commented 5 years ago

any updates regarding this ?

t-mullen commented 5 years ago

Review the pinned troubleshooting and open a new, specific issue if those steps do not work for you.

yaniv-fink commented 5 years ago

It seems that this problem was not solved yet. I have the same problem, getting Ice connection failed Only when creating video from firefox to chrome (chrome to firefox work great) (I am using simple peer and Angular 7) My observation is this.

This is not a firewall problem. (happen in my network, and I closed all firewall and antivirus This is not STUN TURN problem, I checked the URLs they are all valid, and I used big companies like Twilio and Xirsys both lead to the same error

It might be some chrome timeout after 15 seconds, or problem in the simple peer library, I am not sure I noticed that someone opened a chrome bug https://bugs.chromium.org/p/chromium/issues/detail?id=811000 But I checked in later chrome versions the bug was not solved.

Here is some data while debugging the WebRTC image

yaniv-fink commented 5 years ago

It seems that the problem was when I loaded the IceServer from my server, into the peer object I used a wrong configuration, (did not initiate it properly) now it is working, (although it is not working from chrome using iPhone, I guess this is Apple lack of support in WebRTC, but this is another story...)