node.js - Serving socket.io via https -


i got code:

var io = require('socket.io').listen(443); var redis = require('redis'); 

thinking can load socket.io client via

https://<my ip>/socket.io/socket.io.js 

but error

ssl connection error 

it works fine http , port 80. need working serving https?

update:

i have managed update code, here share community:i socket.io.js served client cant subscription redis channels working quite yet.

so here latest code:

var https = require('https'); var fs = require('fs'); var socketio = require('socket.io'); var redis = require('redis');  var nclients=0; var nport = 6800;              // port of redis server var nhost = "123.123.123.123";  // host running redis server var spass = "mysecretpassword";   var svrport = 443; // port of service var svroptions = {     key: fs.readfilesync('/etc/ssl/private/my.key'),     cert: fs.readfilesync('/etc/ssl/private/my.crt'),     ca: fs.readfilesync( '/etc/ssl/private/cabundle.crt') };  var servidor = https.createserver( svroptions , function( req , res ){     res.writehead(200);     res.end('ok'); });  io = socketio.listen( servidor );  // listen in specified port servidor.listen( svrport );  cli_sub = redis.createclient(nport,nhost); cli_sub.auth(spass, function() {console.log("connected!");});  cli_sub.subscribe("mychannel");  cli_sub.on("message",function(channel,message) {     console.log("incoming message");     console.log(message);     io.sockets.emit('statsout', message); }); 

oh, way, don't forget connect redis in rails app with:

redis = redis.new(:host => 'localhost', :port => 6800, :password=>"mysecretpasswqord") 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -