set node js to https and use wss

634 views
Skip to first unread message

matt

unread,
Feb 24, 2015, 8:49:43 AM2/24/15
to kur...@googlegroups.com
Hello,

It is possible to configuration node js to use https and to simultaneously use wss ?

I tried to set up the Hello world from the tutorial in nodejs Ti use both.

I succeed to make it worK with 'WSS' but when I configure the server.js to use https it seems that the POST REST query is not going throw https ( use.post ).

Do I have to use some kind of gateway to convert the https request to http on nodejs side ?

Thank you by advance

matt

unread,
Feb 24, 2015, 5:33:58 PM2/24/15
to kur...@googlegroups.com
Hello,

Here are more details about what I've done so far.

I followed the tutorial to setup websocket to WSS.

When I start KMS, I see that listening correctly on the port 8433. I also checked with wscat and the websocket server is accessible. Note that I use the -n options as I don't present any certificate with this test.

matth$ wscat --connect wss://192.168.130.3:8433 -n
connected (press CTRL+C to quit)
disconnected


When I start the hello world tutorial it's working. The page is accessible with HTTP and I can see with TCPDUMP that the connection to websocket is using the WSS port ( 8433 ).


Now I try to set SSL on the server node js  Here is what I've try to do in the server.js :

change : as_uri from http to https and change the port to 8443. Use 'fs' to initiate set the cert and change the "server" variable in order to use SSL. :
....

var path = require('path');
var fs = require('fs');
var express  = require('express');
var minimist = require('minimist');
var url = require('url');
var kurento = require('kurento-client');

var argv = minimist(process.argv.slice(2),
{
  default:
  {
    as_uri: "https://xx.xx.xx.xx:8443/",
    ws_uri: "wss://xx.xx.xx.xx:8433/kurento"
  }
});

var app = express();
var https = require('https');
var bodyParser = require('body-parser');
app.use(bodyParser.text({type : 'application/sdp'}));

var pipeline = null;

var asUrl = url.parse(argv.as_uri);
var port = asUrl.port;


var options = {
    key: fs.readFileSync('/etc/kurento/server.key'),
    cert: fs.readFileSync('/etc/kurento/server.crt'),
        requestCert: true,
        passphrase: ""
};

....
.....
Here the creation of the server :

var server = https.createServer(options, app).listen(port, function() {
    console.log('Kurento Tutorial started');
    console.log('Open ' + url.format(asUrl) + ' with a WebRTC capable browser');
});


*/ instead of
//       var server = app.listen(port, function() {
//       console.log('Kurento Tutorial started');
//       console.log('Open ' + url.format(asUrl) + ' with a WebRTC capable browser');
});*/

When I start the server with npm start I don't have errors, I can also see we lsof / netstat that the node js is listening on the port 8443. The page is accessible with HTTPS. But when I click on the bottom start, I have a  problem when the index.js is submitting the "POST" REST ( HTTP ) command to 'helloword' and create a problem of "cross domain".

See the attachment showing the error in the console.

If by any chance you have an idea how to solve that.

Thank you by advance.
img.png

Ivan Gracia

unread,
Mar 11, 2015, 7:14:43 AM3/11/15
to Kurento Public
Hi Matt,

I don't see where your problem could be. Can you check to which address is your AJAX request being sent?

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.

Reply all
Reply to author
Forward
0 new messages