socket()在连接到上游动作电缆Ruby on Rails时失败(24:打开的文件太多)

问题描述 投票:0回答:1

我们正在使用RubyOnRails进行聊天应用程序项目。我们开发的应用程序可在本地正常运行,没有任何问题。但是,尝试从外部连接Web套接字时会出现错误。我们的要求是使用Android应用程序中的这些聊天应用程序api。

我们正在使用以下技术/框架

  • Rails 5.0.0
  • Ruby 2.2.2
  • 动作电缆
  • 乘客
  • Nginx
  • Redis

/ etc / nginx / sites-enabled / chatroom_demo

server {
  listen 80 default_server;
  server_name xx.xxx.xxx.xxx;
  passenger_enabled on;
  passenger_app_env production;
  root /home/projects/chatroom_demo/public;

  location /cable {
       passenger_app_group_name chatroom_demo_action_cable;
       passenger_force_max_concurrent_requests_per_process 0;

       proxy_pass http://xx.xxx.xxx.xxx;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
    }
}

/ etc / nginx / nginx.conf

user www-data;
worker_processes auto;
worker_rlimit_nofile 16384;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 20000;
    # multi_accept on;
}

config / cable.yml

production:
  adapter: redis
  url: redis://localhost:6379

config / environments / production.rb

config.action_cable.url = [/ws:\/\/*/, /wss:\/\/*/]
config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]

我们要使用以下代码连接客户端:

let socket = new WebSocket("ws://XX.XXX.XXX.XXX/cable");

socket.onopen = function(e) {
  alert("[open] Connection established");  
};

socket.onerror = function(error) {
  alert(`[error] ${error.message}`);
};

客户端错误:Undefined服务器端错误:

* 32764 socket()在连接到上游时失败(24:打开的文件太多),客户端:XX.XXX.XXX.XXX,服务器:XX.XXX.XXX.XXX,请求:“ GET /电缆HTTP / 1.1”,上游:“ http://XX.XXX.XXX.XXX:80/cable”,主持人:“ XX.XXX.XXX.XXX”

我们尝试了许多不同的方法来解决此问题,但找不到任何可能的解决方法。

ruby-on-rails nginx websocket actioncable
1个回答
0
投票

您是否也将sysd nolimitfile设置更新为> worker_rlimit_nofile 16384?更多信息in this solution

© www.soinside.com 2019 - 2024. All rights reserved.