Simple-peer: Connexion FAiled

Created on 15 Apr 2020  路  19Comments  路  Source: feross/simple-peer

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

_Originally posted by @t-mullen in https://github.com/feross/simple-peer/issues/202#issuecomment-441994748_

I really don't understand the solver of the problem about not a STUN problem and by the end, he said that was a STUN problem ?? how can i resolve this ? in the same browser don't work for n-times and after that will connect as well ??? i didn't understand this bihavior ?

need more info question

All 19 comments

I do not understand what is your issue in general and what is wrong with simple-peer specifically form the original message.
Can you clearly describe it?

@athina635 That issue has several people talking about very different situations, so I understand if it's confusing (also why I closed it).

An ICE failure is a general networking issue that can have lots of different causes. I recommend focusing on the troubleshooting steps below.

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.
  2. Try the latest source code for simple-peer (not the latest npm release).

  3. Your STUN or TURN servers are not configured properly.

  4. Ensure you can connect to your STUN/TURN servers with this tool: https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
  5. Ensure you receive at least one relay candidate (from the TURN server).
  6. Make sure you are using urls and not url in the iceServers config.
  7. You specified a config object with no iceServers.
  8. Try using your own STUN servers instead of default/public ones (which can be unreliable).

  9. There is a problem with your signalling channel.

  10. Ensure latency on signalling messages is not too high (above 10 seconds).
  11. Ensure all signal messages are being delivered.

  12. Your firewall or internet provider is blocking WebRTC traffic.

  13. Try disabling your firewall first, if it works, test the following:
  14. Append "?transport=tcp" to your TURN config to avoid UDP rules.
  15. Configure your TURN server to use port 443 to avoid port rules.
  16. Use TLS over TCP to avoid packet analysis rules.
  17. You WILL NOT need to disable firewalls in production.

  18. You have found a new bug, or a rare case we haven't discussed here.

  19. 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/

@t-mullen thank you for your suggestions. I will give you what I found already step by step:

1/Try the latest source code for simple-peer (not the latest npm release).
I'm using the function found on the npm simple-peer web page with sockets. and the connection established between a lot but not all of my users.

2/Your STUN or TURN servers are not configured properly.

I'm using the following conf:

new Peer({
                            initiator: false,
                            wrtc: wrtc,
                            iceTransportPolicy: 'relay',
                            config: {
                                'iceServers': [{
                                    'urls': 'stun:stun.l.google.com:19302'
                                }]
                            },
                            stream: stream,
                            trickle: false

3/ Ensure you receive at least one relay candidate (from the TURN server).
I'm not using a TURN server, I don't know what is it and if that's a required part for the equation.

4/ Try using your own STUN servers instead of the default/public ones (which can be unreliable).
How to do that, and at which configuration I should od that server?

You're forcing TURN with iceTransportPolicy: 'relay', but have no TURN url in iceServers.

You can setup a coturn TURN server or pay a service like Twilio.
https://github.com/coturn/coturn
https://www.twilio.com/stun-turn

Some users have network conditions that require TURN. If you're trying to make an application that works for everyone, all the time, you'll need TURN.

@nazar-pc @t-mullen For my use case, when I tried to connect on my home with different devices it works very well, and I could connect multiple peers together cuz I'm trying to make one to multi-connection(broadcasting) and I succeed to do that with sockets. the problem is going as follow: when i tried to connect with my firnds sometimes i could do that perfectly, sometimes the connection failed without changing the code or something else. that why i could't understand the problem.

is that clear? i here for any more information...Sincerely

@athina635 as Thomas mentioned, you need to use TURN to do that reliably, otherwise you may get lucky and connect or not depending on the network.

Just read online what STUN and TURN are and how they work, those are the fundamental things you need to understand on a decent level.

@nazar-pc @t-mullen iceTransportPolicy: 'relay' is that a necessary thing?
and if my peer configuration is good? (i mean the init)
if that what I need is a TURN server I will pay for one.
so what do you suggest?

You should remove iceTransportPolicy: 'relay'.

Only you can know if it is necessary or not, but most likely no.
Here are the docs: https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection#RTCIceTransportPolicy_enum

@nazar-pc @t-mullen okay thank you both brothers for your interaction,
I remove the iceTransportPolicy: 'relay', so all that I need for now to ensure the connexion every time is to configure a STUN/TURN servers?

Yes, but read what those are first.

I'm closing the issue since it doesn't seem like there is anything to be done in simple-peer itself, but feel free to continue conversation.

@nazar-pc @t-mullen I use the Twilio stun turn server but when I generate the token they gave me, I have multiple stun and turn servers in the result.

what can I do? I'm confusing?
using them all ? or just choose between them those who have URLs and not URL or what ??

Use them all 馃憤

@t-mullen i have that message in firefox:

Using more than two STUN/TURN servers slows down discovery

this picture is what i got. i just integrate the ice-servers in creating peer at the simple peer is that right ? i don't integrate the username and the password cuz they are out of the ice servers obj

stun

They are in fact already duplicated in iceServers

@nazar-pc yes they are i note it right now.

but i have a failed connection by the way.. i thought it cus of the multiple STUN/TURN servers.
i will post the error when it appear again.

is that right to use them all ? and why that mesage in firefox ?

failed
@nazar-pc @t-mullen its the connection error why that?

@athina635 multiple servers is fine until you have too much. Twilio will not give you too much, so don't worry about that.
But WebRTC is not something you can copy and paste and have it production-ready unfortunately and there are multiple reasons that can lead to the error like that.
I'm afraid this this not the place where we can walk you through every hoop along the way :disappointed:

Read docs, use dev tools (Chromium have a very useful chrome://webrtc-internals page), those should hopefully give you the answer you're looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

idlatest picture idlatest  路  4Comments

sahil-devzila picture sahil-devzila  路  3Comments

measwel picture measwel  路  4Comments

dnish picture dnish  路  5Comments

alexmarion picture alexmarion  路  4Comments