Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Socket.io work at all with Heroku?

I've tried to find answers to this question and all I can find is old "no it doesn't" or "in the future it will".

I've tried out socket.io-redis with no avail. On Heroku, one dyno will create working sockets, any more than that and you will get the following errors from Socket.io, meaning there is no scaling going on.

{"code":1,"message":"Session ID unknown"}

It seems to me WebSocket "support" Heroku claims to have is really a cruel joke on developers.

Edit: Heroku supports websockets, but it just won't work with socket.io clustering with Redis. So I only run one instance dedicated to sockets. When I want to use sockets with Heroku.

like image 308
John T Avatar asked Sep 05 '14 05:09

John T


1 Answers

disclosure: I'm the Node.js platform owner at Heroku.

tl;dr: We have multi-dyno socket.io support in private beta.

Heroku has full support for WebSockets, which don't require session affinity, and aren't the same thing as socket.io.

Socket.io is a higher-level soft-realtime abstraction that uses WebSockets as one of its many potential transports. Socket.io does require session affinity, and any multi-node event-sharing implementation of socket.io (on Heroku or elsewhere) will require socket.io-redis (or similar).

Most implementations of sticky sessions break 12factor architecture. We've got a flexible, scalable, flip-a-switch sticky session beta running right now for socket.io, meteor, and sockjs users. Email me at [email protected] if you'd like to be added; we'll open it up to the public in the next few weeks.

like image 151
hunterloftis Avatar answered Sep 27 '22 15:09

hunterloftis