WebSocket handshake error: Unexpected response code: 503

I am trying to use websocket rails with angular and heroku. He works in development, but now in production. Here is the code of the server that publishes the event and the client that listens for it.

#Server
WebsocketRails[channel_name].trigger('new_message', @json)

//Client
var dispatcher = new WebSocketRails(window.location.host + "/websocket");
var channel = dispatcher.subscribe(channel_name);
channel.bind('new_message', function(data) {
  $scope.$apply(function(){
    cr.unread_messages += 1;
  });
});

I use SSL in production. I already tried setup

force_ssl = false

in production.rb, but to no avail.

The error I am getting is:

WebSocket connection to 'wss://domain.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 503
+4
source share
1 answer

I had the same problem, my application is behind nginx. Check out my Nginx configurations that worked for me.

location / {
  proxy_pass http://localhost:8080;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Host $host;
}
0
source

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


All Articles