Alexis Alexis - 4 months ago 11x
Node.js Question

"Unexpected response code: 503" in Chrome. Perhaps having to do with on heroku?

I am using with node.js on Heroku. Everything seems to work. However, in the Chrome dev bar, I get

Unexpected response code: 503
. Does anyone know what this could mean? Should I be concerned about it? Will it take up memory in the browser? And if so, can I suppress it?


Heroku "doesn't support" websockets on the Cedar stack yet (no word on when they will) Update: see below. They recommend adding the following code to your implementation:

// assuming io is the Socket.IO server object
io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10); 

The reason for this is that Heroku adds a routing layer on top of your dynos. Your code will be executed on a server, but it's non-deterministic as to which server it will be. Thus, WebSockets can't send data to the "correct" server. Socket.IO will downgrade to long-polling, which keeps the connection alive through the routing layer, ensuring that the events will be executed on the correct server.

UPDATE: Heroku WebSockets is now in public beta! You can add WS support to your app by executing heroku labs:enable websockets -a myapp in your app directory.