我正在 heroku 上设置一个 node.js 推特流媒体应用程序。在第二个客户端建立连接之前,它可以完美运行。这是我在向某人展示之前没想到的:(
我正在为 Twitter Stram API 功能使用 tweet-pipe:https ://github.com/peeinears/tweet-pipe
为了让 Socket.IO 在 Heroku 上工作,我按照以下说明操作:https ://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
在我的 app.js 文件中,我有
io.sockets.on('connection', function (socket) {
tp.stream('statuses/filter', params, false, function (stream) {
stream.on('tweet', function (tweet) {
socket.emit('tweet', tweet );
});
});
});
同样,这一切都很好,直到另一个客户访问该页面。然后原始连接丢失,而第二个客户端有连接。有什么想法吗?我对 Socket.IO 的东西有点陌生。