Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )

904 views Asked by At

I've a Rails Application with nginx & passenger and i've followed the instructions here but keep getting Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )

I've added the block below as docs suggest

location /cable {
    passenger_app_group_name app_name_action_cable;
    passenger_force_max_concurrent_requests_per_process 0;
}

but the error still exists and also i've tried all solutions here on stackover flow but no luck any help?

  redis: &redis
  adapter: redis
  url: redis://localhost:6379/1

  development: *redis

  test: *redis

  production:
   adapter: redis
   url: <%= Rails.application.credentials[Rails.env.to_sym][:redis_url] %>
1

There are 1 answers

0
Vasiliy Novikov On BEST ANSWER

May be you need some config in your nginx configuration? I do not really worked with passenger, but in my project I use it like:

  upstream socket_server {
    server <your_ip>:<your_port>;
  }

  location /cable {
     proxy_pass http://socket_server;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
  }

I use anycable gem, with golang socket server, and it may have differences with passenger and default actioncable but may be my answer can help to rid of your problem

(Also, I strongly recommend to move on anycable because it is consumes the least server resources:))