Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple dynos on Heroku + socket.io broadcasts

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.

like image 737
electrichead Avatar asked Feb 07 '13 15:02

electrichead


People also ask

Does socket IO work on Heroku?

Socket.io + NodeJS doesn't work on Heroku.

Can a socket IO and express on same port?

On Scalingo, your application must listen to the port defined in the PORT environment variable dynamically defined by the platform.

What is the difference between WebSocket and socket IO?

Key Differences between WebSocket and socket.ioIt provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.


1 Answers

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.

like image 133
friism Avatar answered Oct 29 '22 19:10

friism