Heroku + socket.io上的多个dynos广播 [英] Multiple dynos on Heroku + socket.io broadcasts
问题描述
我似乎遇到了一个问题,那就是我的node.js应用程序在Heroku中广播的socket.io在我有超过1个dyno时似乎不起作用。只要我将它缩放到1,它就可以很好地工作。有什么我需要知道的吗?也许有不同的方式向所有的dynos播放?如果我需要提供更多的信息或代码,请告诉我。
您必须将socket.io配置为使用非内存中会话存储,如 RedisStore
。 socket.io 文档中有详细信息,还有更多讨论< a href =https://stackoverflow.com/questions/11064826/using-socket-io-and-redis-on-heroku-with-node-js>这里。 I seem to be having an issue where socket.io broadcasts in my node.js app on Heroku don't seem to work when I have more than 1 dyno. As soon as I scale it to 1, it works perfectly. Is there anything I need to know about this? Maybe there is a different way to broadcast to all dynos? Please elt me know if I need to provide more info or code.
If you're running on multiple dynos/servers then you have to configure socket.io to use a non-in-memory session store like the RedisStore
. The socket.io documentation has details and there's more discussion here.
这篇关于Heroku + socket.io上的多个dynos广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!