Skip to content

Peer constructor option for iceServers ignored #404

Description

@jarretttaylor

I tried to pass in a custom ice server to the Peer constructor, but it is not being used for some reason. I followed the calls and this is what I found.

defaultConfig is created and ice servers configured:
https://github.com/peers/peerjs/blob/master/lib/util.js#L1

defaultConfig assigned to util.defaultConfig:
https://github.com/peers/peerjs/blob/master/lib/util.js#L68

util.defaultConfig assigned to Peer.options.config:
https://github.com/peers/peerjs/blob/master/lib/peer.js#L32

RTCPeerConnection created with Peer.options.config rather than Peer.options:
https://github.com/peers/peerjs/blob/master/lib/negotiator.js#L116

That last one seems like the issue to me (that is, if you are supposed to be able to pass in a custom ice server in the Peer constructor).

For reference, here is some example code.

var myId = 'myGeneratedId';
var myIceServers = [{ 'url': 'stun:custom.stun.server:3478' }];
var myServerHost = window.location.hostname;
var myServerPort = window.location.port || 443;

var myPeer = new Peer(myId, {iceServers: myIceServers, host: myServerHost, port: myServerPort, secure: true});
// Note: event handlers not included in this example
var myConn = myPeer.connect(myId);

I was able to utilize a custom ice server by overwriting the util.defaultConfig value prior to calling the Peer constructor. I am not sure if that is the intended usage, but it worked.

util.defaultConfig = {'iceServers': [{ 'url': 'stun:custom.stun.server:3478' }]};

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions