Websocket not working with socket.io in heroku

My application works fine in localhost with socket.io using websockets and xhr-polling, and it works with xhr polling in heroku, but since heroku provided websocket support, I cannot get it to 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 have already enabled websocket labs.

Is there any working websocket example using socket.io?

+6
source share
1 answer

I had the same problem and I just fixed it with help , restoring websockets in my application to the hero. For some reason, he accidentally switched to the XHR poll.

I used this command from heroku website (@ https://devcenter.heroku.com/articles/heroku-labs-websockets ) to activate it:

heroku labs:enable websockets -a myapp

Then I restarted my server by clicking on the hero and restarting it (or using: heroku restart ).

I also have a working copy of a very simple socket.io chat application (written by Smitha Milli) running on http://calm-gorge-8474.herokuapp.com/ which you can check.

Hope this helps!

+17
source

Source: https://habr.com/ru/post/956976/


All Articles