Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
socket() failed (24: Too many open files) while connecting to upstream Action cable Ruby on Rails

We're working on chat app project using RubyOnRails. The app we developed working on local without any issue. However, it gives an error while trying to connect the web socket from outside. Our requirement is to use these chat app apis from an Android app.

We're using following technologies/frameworks

  • Rails 5.0.0
  • Ruby 2.2.2
  • Action cable
  • Passenger
  • 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:\/\/*/]

Client side we're tying to connect using following code:

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

Client side error: Undefined Server side error:

*32764 socket() failed (24: Too many open files) while connecting to upstream, client: XX.XXX.XXX.XXX, server: XX.XXX.XXX.XXX, request: "GET /cable HTTP/1.1", upstream: "http://XX.XXX.XXX.XXX:80/cable", host: "XX.XXX.XXX.XXX"

We have tried many different ways to fix this issue but couldn't find any potential fix.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Did you also update your sysd nolimitfile settings to be something > worker_rlimit_nofile 16384? More info in this solution.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!