user782220
user782220

Reputation: 11187

Realtime websocket-like behavior possible on Heroku?

I am considering making a chess app in Rails where moves need to be pushed from the server to the client browser asynchronously (ideally with websockets).

However, from what little research I've done it appears that Heroku does not support websockets. But there is an alternative in using socket.io configured to use long polling instead of websockets.

Is long polling insufficient to achieve latency requirements for something like a 5 minute blitz game of chess?

Upvotes: 0

Views: 1865

Answers (2)

William Billingsley
William Billingsley

Reputation: 771

An alternative that's much closer to Websockets is Server Sent Events. It's one-way from server to client (you can just keep making standard requests for the client->server direction).

Heroku does appear to support Server Sent Events, as do most browsers that support Websockets (IE10 being the exception that doesn't).

Upvotes: 0

leggetter
leggetter

Reputation: 15467

The Heroku Cedar stack supports HTTP Streaming and Long Polling: https://devcenter.heroku.com/articles/request-timeout#longpolling_and_streaming_responses

It doesn't support WebSockets. But you can use a framework like Faye and use XHR as the transport mechanism. It seems there's a project for this. See: Is it possible to host FAYE, on Heroku?

If you want to use WebSocket in your game client and have your backend on Heroku then the only solution that I know of right now is to use the Pusher (who I work for addon): https://addons.heroku.com/pusher

Upvotes: 1

Related Questions