February 2018
Thanks for your post. All steps’ve been done including Scaledron ID and changing http to https. All is on a server.
But I see only myself in the left video container (see your html), my remote friend see only himself on the same place in the left container. What is wrong?
1 reply
February 2018
▶ Pavel_Afonin
It seems that scaledrone or java script sees me as a remote user, I think that your example misses an essential part which is how to become a local user, there should be some simple register form, for instance, where I can input my secrete key or some access code. Right? I’m dumb at this, not a programmer at all.
2 replies
February 2018
▶ Pavel_Afonin
I pinged the author to see if he can chime in on this, for RTC is not my area of familiarity 
February 2018
▶ Pavel_Afonin
Hey Pavel, could you link your site so I could check the JavaScript code. It’s hard to guess what could be wrong otherwise.
1 reply
February 2018
▶ sergee
Hi sergee, JavaScript code is fine. It is the same as in the post, I’ve only changed Scaledrone channal ID (I registered to Scaledrone), so it works as the example one does only for remote users. You may check the example (see the post), it works the same as my page does. Now I understand that the code doesn’t provide some registration form to accept my ip address, or how it works I don’t know, to set me as a local user. Scaledrone provide a registration solution to a site, but it is all for programmers, my occupation is different, I can only use a ready solution.
February 2018
You are correct. Scaledrone simply offers a way to connect two hosts and is targeted for developers. If you want an out of the box video solution I highly recommend looking into a ready solution.
Unfortunately I’m not exactly sure what is going wrong. If you still want to use Scaledrone then please upload and share the project with me, otherwise it’s impossible for me to debug it.
1 reply
January 2020
Hey Kirupa
Thanks for interesting tutorial and simple solution for a video chat.
I recreated your example and it works when both peers are in the same local network.
However when one is on local wi-fi and seccond is on cellural network the video chat doesn`t start. It is strange because the script detects 2 members and I can send text messages between peers, only the video chat does not fire up.
Any ideas why? Maybe it is some security limitation in browser??
Thanks in advance
1 reply
January 2020
▶ Maciej_Wojnicki
Is the video the only thing that isn’t playing via the cellular network? Does the browser developer tools console show any errors? For the cellular test, are you viewing on a mobile device? If so, which device? 
May 2020
firstly, thank u for this project, this is very good for me… but how can 3 or much person connected for group chat? i can’t this 
1 reply
May 2020
▶ Engin_Varol_Demirel
That will require a more elaborate setup on the server. I would look into custom 3rd party streaming services for that level of functionality 
May 2020
The NAT traversal with STUN doesn’t work. I ran the demo with one computer on WIFI and the other on cellular hotspot and it doesn’t work
May 2020
▶ sergee
Hi! I have the same problem. I open the url in two differents devices and in both I see myself as localvideo. I changed the ID, but doesn´t work. I need help, please.
May 2020
How well would this work on a security camera controlled using a Raspberry Pi? The application uses the Nodejs webserver running express framework to handle pan, tilt and zoom. Do you think it will work ? Thanks, your code has been the best documented I have found
October 2020
i also have the same problem i only see the local video. when we connect the same network its working fine but when we connect different devices with different network it only shows the local video please anyone give me the solution for this
thanks in advance…!
1 reply
November 2020
November 2020
▶ jeeva_mugunthan
This method is incompatible with the safari browser if that is what you are trying to use.
March 2021
Hello,
I have two different webcams, how do I add the button / task that I can switch between?
Also, can the participant switch between my cameras?
“For example, if the participant wants to see my detail camera, he / she can select it over the system, if he / she wants a general view, he / she should choose my other camera.”
Thanks in advance
1 reply
March 2021
▶ artdzy
Are both webcams connected to the same machine?
1 reply
March 2021
▶ artdzy
March 2021
You’re a gorgeous person, I’ll try right away.
I hope I can.
March 2021
▶ kirupa
I’m trying, but I guess it’s not what I want.
My goal is to ensure that the person connecting to the call can switch between my cameras.
You can see my cameras with a “camera switch” button.
How can I do this by changing where in the code line below?
// Generate random room name if needed
if (!location.hash) {
location.hash = Math.floor(Math.random() * 0xFFFFFF).toString(16);
}
const roomHash = location.hash.substring(1);
// TODO: Replace with your own channel ID
const drone = new ScaleDrone(‘2xmbUiTsqTzukyf7’);
// Room name needs to be prefixed with ‘observable-’
const roomName = ‘observable-’ + roomHash;
const configuration = {
iceServers: [{
urls: ‘stun:stun.l.google.com:19302’
}]
};
let room;
let pc;
function onSuccess() {};
function onError(error) {
console.error(error);
};
drone.on(‘open’, error => {
if (error) {
return console.error(error);
}
room = drone.subscribe(roomName);
room.on(‘open’, error => {
if (error) {
onError(error);
}
});
// We’re connected to the room and received an array of ‘members’
// connected to the room (including us). Signaling server is ready.
room.on(‘members’, members => {
console.log(‘MEMBERS’, members);
// If we are the second user to connect to the room we will be creating the offer
const isOfferer = members.length === 2;
startWebRTC(isOfferer);
});
});
// Send signaling data via Scaledrone
function sendMessage(message) {
drone.publish({
room: roomName,
message
});
}
function startWebRTC(isOfferer) {
pc = new RTCPeerConnection(configuration);
// ‘onicecandidate’ notifies us whenever an ICE agent needs to deliver a
// message to the other peer through the signaling server
pc.onicecandidate = event => {
if (event.candidate) {
sendMessage({‘candidate’: event.candidate});
}
};
// If user is offerer let the ‘negotiationneeded’ event create the offer
if (isOfferer) {
pc.onnegotiationneeded = () => {
pc.createOffer().then(localDescCreated).catch(onError);
}
}
// When a remote stream arrives display it in the #remoteVideo element
pc.onaddstream = event => {
remoteVideo.srcObject = event.stream;
};
navigator.mediaDevices.getUserMedia({
audio: true,
video: true,
}).then(stream => {
// Display your local video in #localVideo element
localVideo.srcObject = stream;
// Add your stream to be sent to the conneting peer
pc.addStream(stream);
}, onError);
// Listen to signaling data from Scaledrone
room.on(‘data’, (message, client) => {
// Message was sent by us
if (client.id === drone.clientId) {
return;
}
if (message.sdp) {
// This is called after receiving an offer or answer from another peer
pc.setRemoteDescription(new RTCSessionDescription(message.sdp), () => {
// When receiving an offer lets answer it
if (pc.remoteDescription.type === 'offer') {
pc.createAnswer().then(localDescCreated).catch(onError);
}
}, onError);
} else if (message.candidate) {
// Add the new ICE candidate to our connections remote description
pc.addIceCandidate(
new RTCIceCandidate(message.candidate), onSuccess, onError
);
}
});
}
function localDescCreated(desc) {
pc.setLocalDescription(
desc,
() => sendMessage({‘sdp’: pc.localDescription}),
onError
);
}
1 reply
March 2021
▶ artdzy
A remote person changing your local camera is difficult (or impossible) to implement, for there are security implications that block this behavior. This is something that you have to initiate through an action on your local machine itself.
Have you seen examples of apps or services that are able to do what you are trying to do?
1 reply
March 2021
▶ kirupa
I do not know such a system. However, it was possible to switch between online traffic cameras and security cameras.
I’m running your source code on https://artunduzay.com/digitalinspection/index.
Is it possible to show two cameras at the same time as User and Enviroment and add “ull screen” feature?
In this case, the participant can view the camera he wants to watch in full screen.
The microphone will remain the default device.
If you can help me with this, I would be very happy.
I don’t want to take any more of your time.
Thanks in advance,
March 2021
Unfortunately no, that isn’t possible either. The media capabilities in the browser aren’t quite as feature-rich as what you describe. You can only have one video source and one audio source active at any one time - even if your system has multiple sources available 
1 reply
March 2021
sample1- I can get two camera streams in the link below.
multiple camera stream sample
sample2- In the link below, I can stop this camera and make it full screen.
webcam/camera streaming via video player template
What I want is to add the simultaneous broadcasting feature of (sample1) two cameras to the code you wrote, and (sample2) to make it full screen and pause as in the video player interface.
The microphone can remain the default device.
Can you please check it?
1 reply
March 2021
▶ artdzy
Did you have a chance to check? @kirupa
March 2021
Hi really simple and helpful post to start with WebRTC. Is this possible to Record this 1:1 Video chat along with Audio ? if yes then can someone guide in right direction please.
April 2021
Hello Sir Thank you for this tutorial I found this helpful.
But I am facing an issue in connecting using different network.
I am using one device on my wifi and other device on my cellular network but I can’t create stream in this way. kindly guide me.
February 2022
can anyone help me change it to use MQTT instead of scalardrone !!