Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket connection to 'wss://staging.example.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 301 #432

Open
arif-muhammad-wmc-tech opened this issue Sep 20, 2016 · 0 comments

Comments

@arif-muhammad-wmc-tech
Copy link

I using Rails 4.1.5, Ruby 2.2.3 and ngnix on staging environment. Installed and configured websocket on development environment without any issues.Staging environment started getting the following error when I deployed:
WebSocket connection to 'wss://staging.example.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 301

Here is my ngnix configuration:

  location /websocket {
   proxy_pass http://staging.example.com/websocket;
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "Upgrade";
   proxy_set_header  X-Real-IP  $remote_addr;
   add_header Access-Control-Allow-Origin *;
   proxy_set_header Upgrade websocket;
   proxy_set_header Connection upgrade;
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   }

JS:
var dispatcher = new WebSocketRails(window.document.location.host + '/websocket');

config/staging.rb
config.force_ssl = true

Tried different ngnix settings but didn't work. Where I'm doing the mistake ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant