Simple-peer: Multiple stun servers

Created on 20 Jun 2019  路  4Comments  路  Source: feross/simple-peer

Hi Feross, just a question here, what about to set multiple stun servers for high availability?

question

All 4 comments

You can pass those as part of your options (see iceServers) below. The following example was trimmed down from the README.

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

Use the config option. Each element in config.iceServers is a "grouping" of redundant server urls. They should be backups for each other.

new Peer({
  config: {iceServers: [
    {urls: [
      'stun:stun.a-primary.com:19302', 
      'stun:stun.a-secondary.com:19302', 
      'stun:stun.a-backup.com:19302'
     ]},
     {urls: [
      'stun:stun.b-primary.com:19302', 
      'stun:stun.b-secondary.com:19302', 
      'stun:stun.b-backup.com:19302'
     ]},
     {
     username: "webrtc",
     credential: "turnpassword"
     urls: [
      'turn:turn.a-primary.com:19302', 
      'turn:turn.a-secondary.com:19302', 
      'turn:turn.a-backup.com:19302'
     ]}
]}
})

@jarretttaylor While that will work and is correct when stun servers can potentially give different candidates, redundant/backup servers should be specified in the same urls array (so you only query one of them).

Thanks mate :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnish picture dnish  路  5Comments

contra picture contra  路  6Comments

feross picture feross  路  3Comments

feross picture feross  路  4Comments

idlatest picture idlatest  路  4Comments