问题
I am developing a node.js application with Socket.io and deploying same on Heroku Dyno. Socket.io is using RedisStore with its PUB/SUB. Socket.io client works perfectly fine with one dyno in heroku. But when I increase the number of dyno to more than one (say two), socket io client request does not work.
Please let me know if any specific configuration on client side is needed while setting up heroku for multiple web dyno having socket.io support.
回答1:
Sorry, but heroku doesn't support sticky session and it's not supported by Socket.io
Sticky load balancing If you plan to distribute the load of connections among different processes or machines, you have to make sure that requests associated with a particular session id connect to the process that originated them.
Using multiple nodes
回答2:
There's a great thread in an issue on the engine.io github. Helped me understand the issue of sticky sessions, engine.io, and heroku a lot better.
回答3:
Sticky Sessions are now supported by Heroku - but only if you join their development (beta) program.
In my experience Heroku works well with socket.io when combined with the Socket.io_Redis plugin and that enabled setting.
来源:https://stackoverflow.com/questions/21191958/heroku-multiple-dyno-socket-io