Setting up rfc5766 TURN server for WebRTc - webrtc

I am new and sorry for my English.
I am working on WebRTC Video call, i follow and run Demo application that is apprtc.appspot.com its OK locally. but I am getting following error
"XMLHttpRequest cannot load https://computeengineondemand.appspot.com/turn?username=83926066&key=4080218913. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access."
after Googling i find that i have to Run my own TURN server if i have to publish my application on globally.
I follow this https://www.dialogic.com/den/developer_forums/f/71/p/10238/38432.aspx
to Install TURN server i installed server by following this and server in running.
Now my problem is how to use this Server for my application? how to set or get URL of server to call form app?
thanks in advance.

I believe that this one should help you:
var pcConfig = {};
var pcConstraints = {};
var turnServer = {
username:'authUserNameAsConfiguredOnServer',
credential: 'password',
url:'turn:YOUR_SERVER_IP_HERE:YOUR_SERVER_PORT_HERE'
}
pcConfig.iceServers = [turnServer]
var pc = new RTCPeerConnection(pcConfig, pcConstraints);
// use your conn here

Related

Provisional headers are shown socket io

I am trying to set up socket io for the first time in a production env. I think I am running into some CORS related issues.
Currently the error I am getting is
Provisional headers are shown
Server side code:
app.js
app.io.attach(server);
index.js
app.io = require('socket.io')({origins: allowed_header});
On client side:
const socket = io(process.env.SOCKET_ADDRESS);
where socket address is http://localhost:8080 for dev, and https://websiteName.com:8080 for production
The server uses nginx's default port. The app works fine when running locally, but it logs in above error in production env.
Thanks
UPDATE:
I tried to change my local client to connect to remote server. And it works this way as well. It is just my production client now have the following issue:
Failed to load resource: the server responded with a status of 403 (Forbidden)
UPDATE2:
I could not really solve the problem, so instead I just did the following:
origins: ['http://localhost:3000', 'http://localhost:4000', '*:*']
And it works for now, but I'd like to figure out what is going on. I tried to replace : with https://example.com:80, and this didn't work.
Hope this will help with all the CORS error
const cors = require('cors');
app.use(cors());
Docs CORS

WEBRTC, not working between different nets

I'm developing a simple app that uses webrtc for transmitting real-time video in one direction (one sender and one receiver). It uses socket.io and node.js for the signalling.
At this moment, it's albe to transmit real-time video when the sender and receiver are in the same net (the server is already online), but if I use mobile net or if the peers are connected in different wifis it doesn´t work.
Actually, I make a test using public library's wifi and my home wifi and when the sender was in the public wifi it worked.
The message I get in firefox when it fails is :
ICE failed, see about:webrtc for more details
As I've read, webrtc uses STUN/TURN servers to solve problems with net's NATS. I have introduced urls from a STUN and a TURN server but it seems it had no effect.
This is the way I'm 'using' the STUN/TURN servers:
var configuration = { iceServers: [
{
urls: "turn:numb.viagenie.ca",
username: "xxxxxxxx#hotmail.com",
credential: "********"
},
{
urls: "stun:stun.callwithus.com"
}
]};
var pc = new RTCPeerConnection(configuration);
For both sides the same and it seems the servers are up.
So, my final question is, I need to do something else to make sure webrtc is using STUN/Turn servers when it's needed?
Or, do you know any other possible cause for this behaviour?
Everything you know can help a lot, because i couldn't find how to use those servers.
if you need more information, please ask for it.
T
Yes, you need to listen to pc.onicecandidate and send each candidate over your signaling channel to the other side, where you call pc.addIceCandidate with it like this, if using adapter.js:
pc.addIceCandidate(candidate).catch(e => console.log(e))
or like this if not (older syntax):
pc.addIceCandidate(new RTCIceCandidate(candidate)).catch(e => console.log(e))
You can also dump the ICE candidates to see if your settings work (srflx = stun, relay = turn):
var PC = window.RTCPeerConnection || window.webkitRTCPeerConnection;
var server = { urls: "stun:stun.l.google.com:19302" };
var pc = new PC({ iceServers: [server] });
pc.onicecandidate = e => e.candidate && console.log(e.candidate.candidate);
pc.createDataChannel("dummy");
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(e => console.log(e));
You can modify that snippet to include your turn server.
console logs of failed comunication
That's an example of what I get in the console. It seems srflx and relay are used, but at some point I get a null candidate, the error on screenshot is because of i'm trying to log a 'candidate' property of a null object.
Finally, the problem was solved.
It seems that Turn server wasn't working fine. I made a trial account on xyrsis and changed the stun and turn servers and it was solved.
Thank you all.

PayPal works fine on localhost, but fails while works on aws server

I have integrated paypal to my MVC4 application. PayPal dll version 1.5.0.0, NewtonJson dll version 6.0.0.0
At first i got exception at localhost while getting access token
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
string accessToken = new PayPal.Api.OAuthTokenCredential("MyClientId", "MySecretId", sdkConfig).GetAccessToken();
Exception was
Invalid HTTP response: The request was aborted: Could not create SSL/TLS secure channel.
From stackoverflow I got a fix
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
System.Net.ServicePointManager.DefaultConnectionLimit = 9999;
Its currently working fine on my localhost, but getting exception when uploaded and run on AWS windows instance.
Retried 3 times.... Exception in PayPal.HttpConnection.Execute(). Check log for more details.
Can somebody help me on this ?
UPDATE
I have checked with uploading the same code in mochahost server. Its working perfectly there too
My EC2 instance is Windows Server 2008 DataCenter, 32 bit with IIS7
Make sure TCP443 is open on any elastic load balancer (ELB) you are using and in the security group assigned to the EC2 instance. In the OS make sure TCP443 is allowed with Windows Advanced Firewall.

Wiki Parsoid error - cannot connect to Parsoid Server

I'm trying to set Parsoid extension and Visual Editor on my wiki page. It is NOT on my localhost. Those who will use the Visual Editor must log in, but the content of the wiki can be read without logging in.
The address is http://contractor.bg/wikimedia/index.php?title=Main_Page
I downloaded the Parsoid extension (in the extension files there is no settings.js file, so I created it according to an example).
My settings are:
in the LocalSettings.php file:
require_once "$IP/extensions/VisualEditor/VisualEditor.php";
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgHiddenPrefs[] = 'visualeditor-enable';
wfLoadExtension( 'Parsoid' );
$wgVisualEditorParsoidURL = 'http://contractor.bg:2083';
$wgVisualEditorParsoidPrefix = 'wikimedia';
//$wgSessionsInObjectCache = true;
//$wgVisualEditorParsoidForwardCookies = true;
//$wgVisualEditorParsoidTimeout = 120;
I tried with to uncomment the last lines, but it still does not work.
In the settings.js file:
parsoidConfig.setMwApi( 'wikimedia', { uri: 'http://contractor.bg/wikimedia/api.php' } ); // I also tried setting an interwiki value, I am not quite sure what is the difference)
parsoidConfig.serverPort = 2083;
parsoidConfig.serverInterface = 'contractor.bg';
parsoidConfig.strictSSL = false;
parsoidConfig.allowCORS = 'contractor.bg/wikimedia'; // I also tried only contractor.bg)
At the moment when I try to Edit a page with the Visual Editor, I receive an error:
Error loading data from server: 401: parsoidserver-http: HTTP 401. Would you like to retry?
Parsoid is not a MediaWiki extension (well, there was an extension with this name as a support mechanism for the actual Parsoid, but it was never standalone and is no longer required). It is an external service.
You need to actually start the Parsoid service by running node bin/server.js from the Parsoid directory. Ensure it is actually running on the port you specify in the VisualEditor config (2083) - it looks like you have something else there.

libgit2sharp Fetch Failing

I am using libgit2sharp to on a proof of concept to automate fetching, changing, commiting some files, and pushing to a remote origin.
I know that push is still not finished yet, but fetch is in vnext but when I call it:
An error was raised by libgit2. Category = Os (Error).
Failed to connect to host
Here is my code:
using (var repo = new Repository(gitPath))
{
var allBranches = repo.Branches.ToList(); //works fine
var creds = new Credentials() {Username = username, Password = password};
var remote = repo.Remotes.FirstOrDefault(x => x.Name == "origin");
remote.Fetch(credentials:creds); //blows up here
}
Some other details:
My remote is private bitbucket hosted using https. (looks like: https://myusername#bitbucket.org/myRepoOwner/repoName.git)
I am able to fetch and push from the command line, so the repo is working.
The same issue happens when I use repo.Fetch("origin");
This sounds like an issue that was recently fixed in libgit2 (and likely has not yet been integrated into libgit2sharp.)
In the mean time, you should be able to remove the myusername# from your remote URI to work around this problem, eg https://bitbucket.org/myRepoOwner/repoName.git.