A
A
Anton2016-07-08 16:52:48
Ruby on Rails
Anton, 2016-07-08 16:52:48

Why does the error occur: "WebSocket connection to 'ws://site.com/cable' failed: Unexpected response code: 404"?

I am writing an application on RoR 5. I am launching the project on port 3020. I'm doing a chat on this video.

Got to 8:50 in the video. At this stage, I get an error in the browser console:

WebSocket connection to 'ws://site.com/cable' failed: Unexpected response code: 404


And if I prescribe:
App.chat.speak()
It returns false (chat, not room - everything is correct).

Of course, false returns due to an error.

Log:
Started GET "/cable" for HERE_SERVER_IP at 2016-07-09 15:58:46 +0300
Cannot render console from HERE_CLIENT_IP! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Started GET "/cable/"[non-WebSocket] for HERE_SERVER_IP at 2016-07-09 15:58:46 +0300
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: close, HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for HERE_SERVER_IP at 2016-07-09 15:58:46 +0300


What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-07-08
@bingo347

if the socket returns a status other than 101, the connection will not be established
. The default ports are the same as for http - 80 for ws and 443 for wss
if your socket is up on port 3020 and there is no reverse proxy in front of it, then connect like this:
ws:/ /site.com:3020/cable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question