Search code examples
node.jsherokuwebsocketsocket.io

Websocket not working with socket.io in heroku


My app is working fine in localhost with socket.io using websockets and xhr-polling and it's working with xhr-polling in heroku, but since heroku provided support for websocket I can´t make it work using websockets.

My Chrome console shows this message:

WebSocket connection to 'ws://<myherokuapp>.herokuapp.com/socket.io/1/websocket/HBWE2BFvHahlSWk5ppHP' failed: Unexpected response code: 503

I already enabled websocket labs.

Is there any working example of websocket using socket.io?


Solution

  • I had the same problem and just fixed it by reactivating the websockets on my app on heroku. It had just randomly switched over to XHR polling for some reason.

    I used this command from heroku's site (@ https://devcenter.heroku.com/articles/heroku-labs-websockets) to reactivate it:

    heroku labs:enable websockets -a myapp

    I then restarted my server by pushing to heroku and having it rebuild (or using: heroku restart).

    I also have a working copy of a very basic socket.io chat application (written by Smitha Milli) running at: http://calm-gorge-8474.herokuapp.com/ that you can test.

    Hope this helps!