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

Rails5 WebSocket 偶爾 handshake 404 #138

Open
jcsky opened this issue Oct 6, 2016 · 2 comments
Open

Rails5 WebSocket 偶爾 handshake 404 #138

jcsky opened this issue Oct 6, 2016 · 2 comments

Comments

@jcsky
Copy link

jcsky commented Oct 6, 2016

問個 Rails5 WebSocket 的問題
小弟公司的聊天室使用了 Rails5 ActionCable 實作,功能是做出來了
但 production 上偶爾(還滿常出現的 冏)會出現錯誤 VM161:37 WebSocket connection to 'ws://amazingtalker.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

架構上,server 使用 AWS EC2,流量經 CloudFlare(Https and CDN使用)進來

原先以為是websocket連線數不足導致,但我已經把 nginx config 中的 passenger_force_max_concurrent_requests_per_process 設為 0 了,應該沒有連線數的限制了才對

# nginx config
server {
  listen 80;
  listen 443 ssl;
  server_name amazingtalker.com socket.amazingtalker.com;

  root /home/deploy/Amazingtutor/current/public;

  location /cable {
    passenger_app_group_name Amazingtutor_action_cable;
    passenger_force_max_concurrent_requests_per_process 0;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto http;
  }
  passenger_enabled on;

  location ~ ^/assets/ {
    expires 1y;
    add_header Cache-Control public;
    add_header ETag "";
    break;
   }
}

不曉得各位有沒有類似的經驗,或指點一下小弟可以如何查案~?! 哪裡可能有問題~?!

@ihower
Copy link
Member

ihower commented Oct 7, 2016

你的網站是全 https 連線,那個 websocket 連線位置應該要是 wss://
錯誤訊息表示用戶連到 ws://,難怪會 404

@jcsky
Copy link
Author

jcsky commented Oct 8, 2016

謝謝 @ihower~!!

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

2 participants