UPDATE:
我已成功地更新代码,在这里与社会各界分享:我现在明白了socket.io.js提供给客户端,但我不能让订阅Redis的工作相当,但渠道。
因此,这里是最新的代码:
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 the Redis Server
var nHost = "123.123.123.123"; // Host that is running the Redis Server
var sPass = "mySecretPassword";
var svrPort = 443; // This is the 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);
// Now listen in the 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);
});
哦,对了,别忘了与应用程序连接到的Redis在你的轨道:
REDIS = Redis.new(:host => 'localhost', :port => 6800, :password=>"mySecretPasswqord")
来源
2013-08-11 15:09:42
KKK
重复:HTTP:// stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl – incarnate
也许不是一个确切的重复,但如果你按照问题中的步骤@incarnate引用(包括加载你的ssl证书),你应该能够启动并运行。 – dc5