diff --git a/src/MediaSession.js b/src/MediaSession.js index 3f9781258..5aa5a338f 100644 --- a/src/MediaSession.js +++ b/src/MediaSession.js @@ -107,19 +107,24 @@ JsSIP.MediaSession.prototype = { * @param {Function} onSuccess Fired when there are no more ICE candidates */ start: function(onSuccess) { - var idx, server, + var idx, server, scheme, url, session = this, sent = false, servers = []; for (idx in this.session.ua.configuration.stun_servers) { - server = this.session.ua.configuration.stun_server[idx]; + server = this.session.ua.configuration.stun_servers[idx]; servers.push({'url': server}); } for (idx in this.session.ua.configuration.turn_servers) { server = this.session.ua.configuration.turn_servers[idx]; - servers.push({'url': server.username +'@'+ server.server, 'credential': server.password}); + url = server.server; + scheme = url.substr(0, url.indexOf(':')); + servers.push({ + 'url': scheme + ':' + server.username + '@' + url.substr(scheme.length+1), + 'credential': server.password + }); } this.peerConnection = new webkitRTCPeerConnection({"iceServers": servers}); diff --git a/src/UA.js b/src/UA.js index 17ae5df58..8326bb3d7 100644 --- a/src/UA.js +++ b/src/UA.js @@ -665,11 +665,11 @@ JsSIP.UA.prototype.loadConfig = function(configuration) { } } - if (!(configuration.stun_servers instanceof Array)){ + if (configuration.stun_servers && !(configuration.stun_servers instanceof Array)){ configuration.stun_servers = [configuration.stun_servers]; } - if (!(configuration.turn_servers instanceof Array)){ + if (configuration.turn_servers && !(configuration.turn_servers instanceof Array)){ configuration.turn_servers = [configuration.turn_servers]; }