I have the following simple socket.io app :
var fs = require('fs');
var db = require("./libs/db.js");
var sslOptions = {
key: fs.readFileSync('/var/ssl/server.key'),
cert: fs.readFileSync('/var/ssl/server.crt'),
ca: fs.readFileSync('/var/ssl/ca.crt'),
requestCert: true,
rejectUnauthorized: false
};
var io = require('socket.io').listen(4000,sslOptions);
It runs, displaying : info: socket.io started
on launch. The page example.com:4000 outputs : Welcome to socket.io
, all good.
Now, in another directory, I have :
var fs = require('fs');
var sslOptions = {
key: fs.readFileSync('/var/ssl/server.key'),
cert: fs.readFileSync('/var/ssl/server.crt'),
ca: fs.readFileSync('/var/ssl/ca.crt'),
requestCert: true,
rejectUnauthorized: false
};
var io = require('socket.io').listen(2000,sslOptions);
That code (exactly the same??) doesn't output anything on launch...
socket.io versions are identical (1.1.0), both directories are chmoded the same. What could cause such behaviour? How can I debug?
Edit :
When I cp the not working app in the same dir than the working app, it runs... Again, permissions are the same.
I copied the node_modules/socket.io
of the working dir into the non-working one. It now works.
Still haven't got a clue what's happening. Both versions were installed using npm install, and npm socket.io version gave me the same "1.1.0".
I'll leave the question here, as it may help someone. Weird...