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