我正在使用 Socket.IO 0.9.0 来避免此处讨论的断开连接错误:https ://github.com/LearnBoost/socket.io/issues/777
在我的本地机器上一切正常,但在 Heroku 上,客户端每 25 秒继续断开连接。为什么会这样?
这是我的io配置:
io.configure ->
# For heroku
# https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku
io.set "transports", ["xhr-polling"]
io.set "polling duration", 10
# Use Redis to store client logic
# io.set "store", redisStoreSocketIO
# Minify the client libraries
io.enable 'browser client minification'
# Tag for caching or something
io.enable 'browser client etag'
# GZIP client libraries
io.enable 'browser client gzip'
# Make it so sockets doesn't write to log every 3 seconds
io.set 'log level', 1
return
我检查了我的 git 提交日志并确认 Heroku 使用了正确的版本。