electron-webrtc iceServers specify Turn server












0















In my main.js I have a websocket handle new connections which opens a new BrowserWindow loading my rendering.js which uses desktopCapturer to handle the stream and build up the webrtc connection.



I need to use a turn server but am unsure of howto define this as attempts thus far have failed. The app will be built with docker and opening 10k udp ports or bridging onto host network is not feasable.



I have tried define the turn server like



myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: ["turns:turnserver.example.org", "turn:turnserver.example.org"],
username: "webrtc",
credential: "turnpassword"
}
]
});


renderer.js



const {desktopCapturer} = require('electron')
const EventEmitter = require('events');
const {ipcRenderer} = require('electron')
const fs = require('fs')
var socketId = null;
var windowId = null;
var otherConfig;
var windowStreamer;
socketId = require('electron').remote.getCurrentWindow().getTitle();
windowId = socketId;

class WindowStreamer extends EventEmitter {
constructor(windowId) {
super();
this.offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
}
this.peer = new RTCPeerConnection(null); // This is where I think I should define the turn server??? but it did not work.
this.sdp = null;
this.icecandidates = ;
let that = this;
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
if (error) {
throw error
} else {
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name === windowId) {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[i].id,
minWidth: 800,
maxWidth: 1921,
minHeight: 600,
maxHeight: 1081
}
}
})
.then(stream => that.handleStream(stream))
.catch(e => ipcRenderer.send('async',JSON.stringify("Error while trying to access window " + windowId + " video source. " + e)))
}
}
}
})
}
handleStream(stream) {
this.peer.addStream(stream);
this.peer.onicecandidate = e => this.icecandidates.push(e.candidate);
let that = this;
this.peer.createOffer(this.offerOptions).then(desc=> {
that.sdp = desc;
that.peer.setLocalDescription(desc);
setTimeout(that.monitorGatheringState, 100);
}, e => ipcRenderer.send('async',JSON.stringify("Error while creating RTC offer: " + e)));
}
setClientConfig (config) {
config = JSON.parse(config);
let that = this;
this.peer.setRemoteDescription(config.sdp);
config.icecandidates.forEach(candidate => {
if(candidate != null || candidate != undefined) {
let rtcicecandidate = new RTCIceCandidate(candidate);
that.peer.addIceCandidate(rtcicecandidate)
.then(s => {}, e => ipcRenderer.send('async', JSON.stringify('Error whileadding RTCIceCandidate ' + e)))

}
})
let message = {
socketId: socketId
}
}
monitorGatheringState() {
if(windowStreamer.peer.iceGatheringState == "complete") {
windowStreamer.emit("ice-gathering-completed", windowStreamer.sdp, windowStreamer.icecandidates);
let message = {
socketId: socketId,
config: {
sdp: windowStreamer.sdp,
icecandidates: windowStreamer.icecandidates
}
}
} else {
setTimeout(windowStreamer.monitorGatheringState, 100);
}
}
}

ipcRenderer.on('client-webrtc-config', (event, data) => {
otherConfig = data;
windowStreamer.setClientConfig(otherConfig);
})

windowStreamer = new WindowStreamer(windowId);


How should I define my TURN server?










share|improve this question























  • It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

    – music2myear
    Jan 25 at 15:57
















0















In my main.js I have a websocket handle new connections which opens a new BrowserWindow loading my rendering.js which uses desktopCapturer to handle the stream and build up the webrtc connection.



I need to use a turn server but am unsure of howto define this as attempts thus far have failed. The app will be built with docker and opening 10k udp ports or bridging onto host network is not feasable.



I have tried define the turn server like



myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: ["turns:turnserver.example.org", "turn:turnserver.example.org"],
username: "webrtc",
credential: "turnpassword"
}
]
});


renderer.js



const {desktopCapturer} = require('electron')
const EventEmitter = require('events');
const {ipcRenderer} = require('electron')
const fs = require('fs')
var socketId = null;
var windowId = null;
var otherConfig;
var windowStreamer;
socketId = require('electron').remote.getCurrentWindow().getTitle();
windowId = socketId;

class WindowStreamer extends EventEmitter {
constructor(windowId) {
super();
this.offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
}
this.peer = new RTCPeerConnection(null); // This is where I think I should define the turn server??? but it did not work.
this.sdp = null;
this.icecandidates = ;
let that = this;
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
if (error) {
throw error
} else {
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name === windowId) {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[i].id,
minWidth: 800,
maxWidth: 1921,
minHeight: 600,
maxHeight: 1081
}
}
})
.then(stream => that.handleStream(stream))
.catch(e => ipcRenderer.send('async',JSON.stringify("Error while trying to access window " + windowId + " video source. " + e)))
}
}
}
})
}
handleStream(stream) {
this.peer.addStream(stream);
this.peer.onicecandidate = e => this.icecandidates.push(e.candidate);
let that = this;
this.peer.createOffer(this.offerOptions).then(desc=> {
that.sdp = desc;
that.peer.setLocalDescription(desc);
setTimeout(that.monitorGatheringState, 100);
}, e => ipcRenderer.send('async',JSON.stringify("Error while creating RTC offer: " + e)));
}
setClientConfig (config) {
config = JSON.parse(config);
let that = this;
this.peer.setRemoteDescription(config.sdp);
config.icecandidates.forEach(candidate => {
if(candidate != null || candidate != undefined) {
let rtcicecandidate = new RTCIceCandidate(candidate);
that.peer.addIceCandidate(rtcicecandidate)
.then(s => {}, e => ipcRenderer.send('async', JSON.stringify('Error whileadding RTCIceCandidate ' + e)))

}
})
let message = {
socketId: socketId
}
}
monitorGatheringState() {
if(windowStreamer.peer.iceGatheringState == "complete") {
windowStreamer.emit("ice-gathering-completed", windowStreamer.sdp, windowStreamer.icecandidates);
let message = {
socketId: socketId,
config: {
sdp: windowStreamer.sdp,
icecandidates: windowStreamer.icecandidates
}
}
} else {
setTimeout(windowStreamer.monitorGatheringState, 100);
}
}
}

ipcRenderer.on('client-webrtc-config', (event, data) => {
otherConfig = data;
windowStreamer.setClientConfig(otherConfig);
})

windowStreamer = new WindowStreamer(windowId);


How should I define my TURN server?










share|improve this question























  • It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

    – music2myear
    Jan 25 at 15:57














0












0








0








In my main.js I have a websocket handle new connections which opens a new BrowserWindow loading my rendering.js which uses desktopCapturer to handle the stream and build up the webrtc connection.



I need to use a turn server but am unsure of howto define this as attempts thus far have failed. The app will be built with docker and opening 10k udp ports or bridging onto host network is not feasable.



I have tried define the turn server like



myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: ["turns:turnserver.example.org", "turn:turnserver.example.org"],
username: "webrtc",
credential: "turnpassword"
}
]
});


renderer.js



const {desktopCapturer} = require('electron')
const EventEmitter = require('events');
const {ipcRenderer} = require('electron')
const fs = require('fs')
var socketId = null;
var windowId = null;
var otherConfig;
var windowStreamer;
socketId = require('electron').remote.getCurrentWindow().getTitle();
windowId = socketId;

class WindowStreamer extends EventEmitter {
constructor(windowId) {
super();
this.offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
}
this.peer = new RTCPeerConnection(null); // This is where I think I should define the turn server??? but it did not work.
this.sdp = null;
this.icecandidates = ;
let that = this;
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
if (error) {
throw error
} else {
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name === windowId) {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[i].id,
minWidth: 800,
maxWidth: 1921,
minHeight: 600,
maxHeight: 1081
}
}
})
.then(stream => that.handleStream(stream))
.catch(e => ipcRenderer.send('async',JSON.stringify("Error while trying to access window " + windowId + " video source. " + e)))
}
}
}
})
}
handleStream(stream) {
this.peer.addStream(stream);
this.peer.onicecandidate = e => this.icecandidates.push(e.candidate);
let that = this;
this.peer.createOffer(this.offerOptions).then(desc=> {
that.sdp = desc;
that.peer.setLocalDescription(desc);
setTimeout(that.monitorGatheringState, 100);
}, e => ipcRenderer.send('async',JSON.stringify("Error while creating RTC offer: " + e)));
}
setClientConfig (config) {
config = JSON.parse(config);
let that = this;
this.peer.setRemoteDescription(config.sdp);
config.icecandidates.forEach(candidate => {
if(candidate != null || candidate != undefined) {
let rtcicecandidate = new RTCIceCandidate(candidate);
that.peer.addIceCandidate(rtcicecandidate)
.then(s => {}, e => ipcRenderer.send('async', JSON.stringify('Error whileadding RTCIceCandidate ' + e)))

}
})
let message = {
socketId: socketId
}
}
monitorGatheringState() {
if(windowStreamer.peer.iceGatheringState == "complete") {
windowStreamer.emit("ice-gathering-completed", windowStreamer.sdp, windowStreamer.icecandidates);
let message = {
socketId: socketId,
config: {
sdp: windowStreamer.sdp,
icecandidates: windowStreamer.icecandidates
}
}
} else {
setTimeout(windowStreamer.monitorGatheringState, 100);
}
}
}

ipcRenderer.on('client-webrtc-config', (event, data) => {
otherConfig = data;
windowStreamer.setClientConfig(otherConfig);
})

windowStreamer = new WindowStreamer(windowId);


How should I define my TURN server?










share|improve this question














In my main.js I have a websocket handle new connections which opens a new BrowserWindow loading my rendering.js which uses desktopCapturer to handle the stream and build up the webrtc connection.



I need to use a turn server but am unsure of howto define this as attempts thus far have failed. The app will be built with docker and opening 10k udp ports or bridging onto host network is not feasable.



I have tried define the turn server like



myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: ["turns:turnserver.example.org", "turn:turnserver.example.org"],
username: "webrtc",
credential: "turnpassword"
}
]
});


renderer.js



const {desktopCapturer} = require('electron')
const EventEmitter = require('events');
const {ipcRenderer} = require('electron')
const fs = require('fs')
var socketId = null;
var windowId = null;
var otherConfig;
var windowStreamer;
socketId = require('electron').remote.getCurrentWindow().getTitle();
windowId = socketId;

class WindowStreamer extends EventEmitter {
constructor(windowId) {
super();
this.offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
}
this.peer = new RTCPeerConnection(null); // This is where I think I should define the turn server??? but it did not work.
this.sdp = null;
this.icecandidates = ;
let that = this;
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
if (error) {
throw error
} else {
for (let i = 0; i < sources.length; ++i) {
if (sources[i].name === windowId) {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: sources[i].id,
minWidth: 800,
maxWidth: 1921,
minHeight: 600,
maxHeight: 1081
}
}
})
.then(stream => that.handleStream(stream))
.catch(e => ipcRenderer.send('async',JSON.stringify("Error while trying to access window " + windowId + " video source. " + e)))
}
}
}
})
}
handleStream(stream) {
this.peer.addStream(stream);
this.peer.onicecandidate = e => this.icecandidates.push(e.candidate);
let that = this;
this.peer.createOffer(this.offerOptions).then(desc=> {
that.sdp = desc;
that.peer.setLocalDescription(desc);
setTimeout(that.monitorGatheringState, 100);
}, e => ipcRenderer.send('async',JSON.stringify("Error while creating RTC offer: " + e)));
}
setClientConfig (config) {
config = JSON.parse(config);
let that = this;
this.peer.setRemoteDescription(config.sdp);
config.icecandidates.forEach(candidate => {
if(candidate != null || candidate != undefined) {
let rtcicecandidate = new RTCIceCandidate(candidate);
that.peer.addIceCandidate(rtcicecandidate)
.then(s => {}, e => ipcRenderer.send('async', JSON.stringify('Error whileadding RTCIceCandidate ' + e)))

}
})
let message = {
socketId: socketId
}
}
monitorGatheringState() {
if(windowStreamer.peer.iceGatheringState == "complete") {
windowStreamer.emit("ice-gathering-completed", windowStreamer.sdp, windowStreamer.icecandidates);
let message = {
socketId: socketId,
config: {
sdp: windowStreamer.sdp,
icecandidates: windowStreamer.icecandidates
}
}
} else {
setTimeout(windowStreamer.monitorGatheringState, 100);
}
}
}

ipcRenderer.on('client-webrtc-config', (event, data) => {
otherConfig = data;
windowStreamer.setClientConfig(otherConfig);
})

windowStreamer = new WindowStreamer(windowId);


How should I define my TURN server?







linux networking java






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 17 at 20:10









KempyKempy

11




11













  • It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

    – music2myear
    Jan 25 at 15:57



















  • It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

    – music2myear
    Jan 25 at 15:57

















It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

– music2myear
Jan 25 at 15:57





It looks as though you might have created multiple accounts by accident. Please check out our guide on merging your accounts to get this problem fixed: superuser.com/help/merging-accounts

– music2myear
Jan 25 at 15:57










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395525%2felectron-webrtc-iceservers-specify-turn-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395525%2felectron-webrtc-iceservers-specify-turn-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mouse cursor on multiple screens with different PPI

Agildo Ribeiro

Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”