1

I'm currently trying to deploy an application using Rails 5.0.0.beta2 but when I load the application in my javascript console I am seeing

WebSocket connection to 'wss://example.com/cable' failed: Error during WebSocket handshake: 'Connection' header value must contain 'Upgrade'

I'm using Apache/Passenger as the web server.

Has anyone else run into this issue and if so how did you solve it?

Mario
  • 1,213
  • 2
  • 12
  • 37
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
  • Have you solved it yet? – samarth Nov 19 '16 at 12:05
  • I've resolved this issue. actually there are 3 steps to do that: **A) use wss://example.com/cable 2) change port (from 80 to something else) 3) Add your ip in firewall exception.** – samarth Nov 21 '16 at 09:20

1 Answers1

0

The webserver will need to upgrade the websocket connection so the connection can persist. I'm guessing this is not happening from the jscript error you see.

If you were using Nginx here is how you would do it using a Nginx reverse proxy configuration: ActionCable on AWS: Error during WebSocket handshake: Unexpected response code: 404

This is the key part:

      # enables WS support
      location /cable {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
      }

Also consider using puma instead of passenger.

Community
  • 1
  • 1
KeithP
  • 1,803
  • 1
  • 16
  • 23
  • I've changed it. but still no luck :( here is my config file looks like: `location /cable { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; passenger_app_group_name gorails_websocket; passenger_force_max_concurrent_requests_per_process 0; }` – samarth Nov 19 '16 at 12:03
  • is it even possible to use websockets with passenger on an apache server (with nodejs, not ruby)?? – oldboy Dec 16 '18 at 08:58