【问题标题】:Socket.io with HerokuSocket.io 与 Heroku
【发布时间】:2013-09-20 18:12:43
【问题描述】:

这在我自己的计算机服务器上完美运行

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 添加这个 global.io.configure(function () { global.io.set("transports", ["xhr-polling"]); global.io.set("轮询持续时间", 10); });

当我发出消息时,我的服务器端代码如下所示:

exports.getFake = function(req, res){
    global.io.of(global.id).emit('email' , email);    
}

【问题讨论】:

    标签: javascript heroku socket.io


    【解决方案1】:

    Web 套接字在 Heroku 上是实验性的。 你读过这个吗:https://devcenter.heroku.com/articles/heroku-labs-websockets? 您可能也想阅读此内容:heroku multiple dyno socket.io

    【讨论】:

      猜你喜欢
      • 2014-10-30
      • 2017-06-17
      • 2013-03-16
      • 2014-06-27
      • 2016-08-30
      • 2013-11-28
      • 2012-07-25
      • 1970-01-01
      • 2012-08-11
      相关资源
      最近更新 更多