Padma govind
Padma govind

Reputation: 31

How to connect to stun and turn servers using simple peer

I developed a video chatting application using simple peer and socket.io . But when I tried hosting the application the peers could not be connected because of the firewall issue . I am aware that STUN and TURN servers are to be used for this purpose . Is it possible to connect to those servers using simple peer ? If so how? Any explanation or reference articles will be helpful

Upvotes: 0

Views: 3681

Answers (2)

Mohit Gupta
Mohit Gupta

Reputation: 93

If you read the source code of the simple-peer npm package you will realize that it currently uses

URLs: [
  'stun:stun.l.google.com:19302',
  'stun:global.stun.twilio.com:3478'
]

for its public IP discovery needs.

Your app fails to work in case of firewall because just stun server is insufficient in case of firewall.

Besides a STUN server, you need a TURN server is this case.

TURN is the fallback is case STUN fails to deliver.

Upvotes: 1

Dirk V
Dirk V

Reputation: 1469

You can add the iceServer configuration like in original webrtc in the simple-peer config like so:

{
  initiator: false,
  config: { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] },
}

You can add stun servers and/or turn servers.

Upvotes: 3

Related Questions