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?
The normal Heroku HTTP routing timeout rules apply to WebSocket connections. Either client or server can prevent the connection from idling by sending an occasional ping packet over the connection.
Socket.io + NodeJS doesn't work on Heroku.
It provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With