Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using socket.io 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?

like image 564
Alexis Avatar asked Jan 05 '13 18:01

Alexis


2 Answers

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 Socket.io 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.

like image 165
SomeKittens Avatar answered Nov 10 '22 15:11

SomeKittens


For people coming from google in 2016.

Heroku websockets are now supported, no need to turn them on. WebSockets on Heroku

Make sure to check your logs on Heroku. I noticed the 503 error happen in chrome and after checking logs, turned out that my Heroku app had crashed. There was a bug in my code which caused it to not responding (not socket.io related at all)

Fixed the code and 503 went away!

like image 41
Alex G Avatar answered Nov 10 '22 15:11

Alex G