How can I make my ws connection to wss connection in node js

1,018 views
Skip to first unread message

shada...@gmail.com

unread,
Dec 8, 2015, 7:53:42 AM12/8/15
to kurento
Hi There,

How can I make my ws connection to wss connection in node js?? After the latest update, chrome has stopped all its HTTP service for getUserMedia activities. So its mandatory to run in HTTPS protocol, I tried with the following modifications to existing kurento one2many call server.js file. I don't get any errors when I run this file and port 8443 is open an d listening. But if I try to send a message or to connect from chrome browser it throws an error. 
Can anyone please help me out with this and suggest me some ideas to get through it


Error:

WebSocket connection to 'wss://my.ip.address:8443/call' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

Modifications :

var path = require('path');
var express = require('express');
var ws = require('ws');
var minimist = require('minimist');
var url = require('url');
var https = require('https');
var fs = require('fs');
var kurento = require('kurento-client');
var privateKey  = fs.readFileSync('/path/to/key.pem', 'utf8');
var certificate = fs.readFileSync('path/to/cert.pem', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var argv = minimist(process.argv.slice(2),
{
  default:
  {
    as_uri: "https://localhost:8443/",
    ws_uri: "ws://localhost:8888/kurento"
  }
});

var app = express();


/*
 * Server startup
 */

var asUrl = url.parse(argv.as_uri);
var httpsServer = https.createServer(credentials, app);
var port = asUrl.port;
httpsServer = app.listen(port, function() {
console.log('Kurento Tutorial started');
console.log('Open ' + url.format(asUrl) + ' with a WebRTC capable browser');

  console.log('port' + port);
});

var wss = new ws.Server({
server : httpsServer,
path : '/call'
});

/*
 * Management of WebSocket messages
 */

 wss.on('connection', function(ws) {

var sessionId = nextUniqueId();

console.log('Connection received');

});




Thank you,
shadanana

Ivan Gracia

unread,
Dec 9, 2015, 5:54:01 AM12/9/15
to Kurento Public
The tutorials have been modified to use HTTPS by default. Please checkout the last commit from there, and you'll get that wss connection.

In any case, that's not something privy to Kurento or the tutorials, but to nodejs and how to get WSS working there.

Ivan Gracia



--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shada...@gmail.com

unread,
Dec 9, 2015, 8:01:58 AM12/9/15
to kurento, shada...@gmail.com
Thank you Ivan for your quick replay...
Reply all
Reply to author
Forward
0 new messages