STUN and TURN Server - webrtc

I have developed a webrtc based video chat using peerjs. The solution is working fine but some users are facing problem to establish the call. I guess it is due to NAT and firewall issues.
I have user peerjs as :
var peer = new Peer({host: myserver.com], port: 9000, debug: true});
I have changed the code to [passed google stun] as seen here : =
Still the same issue. Some user can not connect to peer id. Am I doing something wrong?

Related

How to setup STUN server in a video chat app built using simple peer?

I was recently working on a project which requires video chatting. I used simple peer to setup a video call and use socket.io for signalling purposes. I then deployed my application. I realised when two peers on the same network join the call, the app works fine. But if two peers on different networks join the call, then I got an error stating process not defined and the call does not connects.
I read about this online and then figured out that I also have two configure a STUN and/or TURN server to extract ICE candidates and their public IP.
Can anyone please tell me how to setup a STUN server in my simple peer application? I have also read somewhere that google provides some free STUN servers to use but I dont know how to actually integrate them in my simple peer application.
When you create the RTCPeerConnection in your application, provide a configuration that includes iceServers.
This is the reference.
Example:
myPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: "stun:stunserver.example.org"
}
]
});
You can find a list of free STUN servers here.
You may also want to configure TURN servers to cover more complex NAT scenarios.

Gathering ice candidates works but failing to connect

I have two different WebRTC clients: an Android device and an angular application. I set up a turn and stun server and both seems to work with the trickle ice tester and the webrtc tester.
As you can see here:
But all ice candidates fail in Firefox when I am watching the candidates in about:webrtc.
Does anyone have an explanation for this?
More info:
A similar error occurs in Google Chrome, but the logs are from Firefox because Firefox has better logging.
The devices are on different networks, so the host request should fail and the turn server is needed.
The turn server is a coturn turn server, but I also tried it with a Pion turn server and the same result occurs.
Firfox logs: https://gist.github.com/Nick-v-L/365b7da10039d28a6a23a27fea15df52
Coturn logs: https://gist.github.com/Nick-v-L/04c3cfc677847e3cdcb7f6b5ca15c743
There was a simple error in my Android app. When receiving an ice candidate from the signaling server I did the following:
peerConnection.AddIceCandidate(new IceCandidate(sdpCandidate, sdpMLineIndex, sdpMid));
But as the documentation states you have to create an ice candidate in this order:
public IceCandidate(string sdpMid, int sdpMLineIndex, string sdp);
So I turned the sdpCandidate and sdpMid around to fix the issue.
peerConnection.AddIceCandidate(new IceCandidate(sdpMid, sdpMLineIndex, sdpCandidate));

Node App is not working correctly on Google App Engine

I have connected my node app to my Cloud SQL database and it is working perfectly locally, but when I deploy my node app to App Engine, the API no longer works. In the logs I can see the following:
(node:11) UnhandledPromiseRejectionWarning: SequelizeConnectionError: connect ETIMEDOUT
This does not happen when I run the app locally despite being connected to the same Google Cloud SQL DB.
I thought maybe it would not connect because of security restrictions, but on the SQL connections page it says the following:
Apps in this project: All authorized.
My node app is deployed within the same project, so that shouldn't be the problem.I have also whitelisted my home IP so that I could connect locally, and that was a success as mentioned before. Any help would be appreciated.
EDIT:
Here is my attempt to connect to the DB. It now fails locally & when I deploy. It works locally if I pass in the public IP to the "host."
const sequelize = new Sequelize('linkspot', 'kyle', 'password', {
host: '/cloudsql/linkspot:us-central1:linkspot-mysql',
dialect: 'mysql',
port: 3306,
pool: {
max: 5,
min: 1,
acquire: 30000,
idle: 10000
}
});
When you connect in your local computer the connection is made via the SQL Proxy, but when the app is deployed in app engine several steps are needed to configure app engine depending if its using private or public IP.
For instance private ip connections requires you to create a Serverless VPC Access connector in the same VPC network as your Cloud SQL instance, and public IP connections require you to use unix domain socket using the format: /cloudsql/INSTANCE_CONNECTION_NAME.
For the instructions on both cases check this doc

WebRTC make a connection between two different devices

Well I am studying about Web-RTC from its official documentation. I need to integrate live streaming in my website but after seeing this and studying about all its documentation. I only learn about streaming on locally like on same browser and same page. But this is not what i want. I want to start stream from my admin panel(This part has been completed) and broadcast that stream whoever has access to my website whatever the website is and whatever device. Whoever open my website if i m streaming then he should see that and if some of u have worked on live streaming then u should tell me. It will be a great help for me. All i did until now is to make a connection between two peers on same page. Now i want to make global peer to peer connection
I have done this implementation using simple-peer. Basically a wrapper for webRTC.
As soon as a new user connects a new webrtc connection should be made between the receiver and the caller. The receiver is firstly initialized and then sends a message to the sender to start the connection. This first connection is all done by your own server you should write.
Here is a working example. And here is the demo. Any connected devices will be automatically connected to the call. Multiple users supported. You'll find all the webrtc code in /public/js/main.js
You have to do signaling which mean that you have to exchange the PEER CONNECTIONS over the server and which required you to build a server page and client page so both of you can exchange the peer connection.
here is the complete procedure of exchanging the peer connection over the server.
find the heading
RTCPeerConnection plus servers
https://www.html5rocks.com/en/tutorials/webrtc/basics/

local stun server inside a closed LTE network

First of all, apologies if the title doesn't match the description.
We, in our organization are working on peer-peer video communication solution within a closedLTE network. For this purpose, we are using open source webrtc client peerjs along with their local peerjs server. The server by default refers to google stun server.
1. Is stun server required in case of closed LTE network?
2. If yes, can we make use of a open source stun server which could run locally instead of the default one?
3. If no, what are the changes I would need to do?
I have setup one open source stun server [https://github.com/enobufs/stun] but failed to carry out further connections with the clients.
I setup the server as per the instructions provided in the link. Now instead of the default stun server , I put the 'local-ip-address:port' and tried to make a connection between the peers. But it dint work.
var configuration = { "iceServers": [{ "urls": "local-ip-address:port" }] };
pc = new RTCPeerConnection(configuration);
Am i doing it the wrong way?
Please guide me through.
Thanks in advance
Coturn is very popular stun/turn server with active community support.
Pre-built packages available at https://github.com/coturn/coturn/wiki/Downloads
You can test the server with sample demo
If both the parties are in same network, then no need to configure turn stuff like credentials. Read more
Configuring the peerConnection:
STUN server: //server_ip is coturn instance ip should be reachable from clients
var iceServers= [{"url": "stun:server_ip:port"}];
or TURN server:
var iceServers= [{"url":["turn:server_ip:port"],"username":"turn_username","credential":"turn_password"}];
var pc_config = {"iceServers": iceServers};
var pc_constraints = {
"optional": [{"DtlsSrtpKeyAgreement": true}]
};
pc = new RTCPeerConnection(pc_config, pc_constraints);