So I'm trying to use NodeJS with Express + Socket.IO.
I've looked at about 5 other stack overflow questions, and looked over the documentation to the point my eyes feel like they're going to bleed!
I've got that to work by the following:
var fs = require('fs'),
privateKey = fs.readFileSync('/path/to/private.key').toString(),
certificate = fs.readFileSync('/path/to/certificate.crt').toString();
var options = {
key: privateKey,
cert: certificate
};
var express = require('express'),
app = express(express.logger()),
https = require('https'),
server = https.createServer(options, app),
io = require('socket.io').listen(server),
routes = require('./routes');
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
server.listen(5050, function() {
console.log("Server a-hoy!");
});
app.get('/', routes.index);
io.sockets.on('connection', function (socket) {
socket.on('givemeresults', function (data) {
io.sockets.emit('results', { some: 'data' });
});
});
Except for the fact that when I run this:
curl https://test.something.net:5050
I get the following (not wanted) results
curl: (35) Unknown SSL protocol error in connection to test.something.net:5050
The whole point of this is so we can use Socket.io in the background of our real webpage to deliver information back to the user.
It works when I use normal http. The certificates are correct as well.
Can you see any possible reason to this failing?
I have had to remove the existing SSL Certificate locations, and the domain name, for security reasons.
Edit:
When running:
[root@example exampleapp]# node app.js
info - socket.io started
Server a-hoy!