无法升级到 WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: ) [英] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )

查看:47
本文介绍了无法升级到 WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 nginx & 的 Rails 应用程序乘客和我已按照此处的说明进行操作,但一直无法升级到 WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE:)

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;
}

但是错误仍然存​​在,而且我已经尝试了 stackover flow 上的所有解决方案,但没有任何帮助?

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] %>

推荐答案

可能你的 nginx 配置中需要一些配置?我并没有真正与乘客一起工作,但在我的项目中我使用它:

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";
  }

我使用 anycable gem,带有 golang 套接字服务器,它可能与 passenger 和默认的 actioncable 有所不同,但我的回答可能有助于解决您的问题

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

(另外,我强烈建议继续使用 anycable 因为它消耗最少的服务器资源:))

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

这篇关于无法升级到 WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: , HTTP_UPGRADE: )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆