1
我试图设置我的生产服务器使用nodejs和HTTPS使用faye消息,但没有运气。Faye与HTTPS nodejs
我直到现在是:
一个王菲+的NodeJS服务器安装文件:
var https = require('https');
var faye = require('faye');
var fs = require('fs');
var options = {
key: fs.readFileSync('/etc/httpd/ssl/example.com.key'),
cert: fs.readFileSync('/etc/httpd/ssl/example.com.crt'),
ca: fs.readFileSync('/etc/httpd/ssl/ca_bundle.crt')
};
var server = https.createServer(options);
var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 60});
bayeux.attach(server);
server.listen(8000);
Rails的助手发送消息:
def broadcast(channel, &block)
message = {:channel => channel, :data => capture(&block)}
uri = URI.parse(Rails.configuration.faye_url)
Net::HTTPS.post(uri, message.to_json)
end
一javascript函数打开一个监听器:
function openListener(channel, callback){
var faye_client = new Faye.Client("<%= Rails.configuration.faye_url %>");
faye_client.subscribe(channel , callback);
return faye_client;
}
我王菲URL配置在production.rb:
config.faye_url = "https://example.com:8000/faye"
最后,在我的页面中调用JavaScript:在测试时
fayeClient = openListener("my_channel" , function(data) {
//do something...
});
一切工作HTTP在开发机器上。但在生产中不。
如果我点浏览器到https://example.com:8000/faye.js我得到了正确的JavaScript文件。
会发生什么?
您的证书是否自签名?我不知道Ruby API,但在制作HTTPS帖子时,在大多数API中,可以选择* not *来验证HTTPS证书,因为证书是自签名的。 – Ankur
是的。我从Godaddy得到 – Beetlejuice