这在我自己的计算机服务器上完美运行
var socket = io.connect('http://localhost:3000');
socket.of(userid).on('email', function (data) {
console.log("here")
});
但是当我切换到heroku时
var socket = io.connect('http://staginggorkemnutrition.herokuapp.com');
socket.of(userid).on('email', function (data) {
console.log("here")
});
似乎从未收到该事件,当我从 heroku 更改为 localhost 时,我也没有更改服务器上的任何内容
ps。 我的服务器中有这个,我知道我必须为 heroku 添加这个 全局.io.configure(函数(){ global.io.set("运输", ["xhr-polling"]); global.io.set("轮询持续时间", 10); });
当我发出消息时,我的服务器端代码看起来像这样:
exports.getFake = function(req, res){
global.io.of(global.id).emit('email' , email);
}
最佳答案
Web 套接字在 Heroku 上处于实验阶段。 你读过这个吗:https://devcenter.heroku.com/articles/heroku-labs-websockets ? 您可能也想阅读此内容:heroku multiple dyno socket.io
关于javascript - Socket.io 与 Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18923213/