0

var WebSocketServer = require('ws').Server
  , wss = new WebSocketServer({port: 978});

Additional information about the system:

ulimit -a | grep file

core file size          (blocks, -c) 0
file size               (blocks, -f) unlimited
open files                      (-n) 999999
file locks                      (-x) unlimited

The system is Ubuntu 14, 1 GB RAM with like 500 MB free on 256 connections, so memory is not an issue.

When connections come, it reaches 256 connections and then stops.

  • What are you using as a client to test the 256 connections? ... could it be that no new connections are being opened on the client side? – Myst May 13 '16 at 07:28
  • I use browser page with javascript socket as a client. Opening multiple tabs, and once 256 is reached on each of a new pages there an error "Socket still in the connecting state". – Valentin Goikhman May 13 '16 at 09:58
  • Myst , you are right. I was opening 256 tabs in Chrome, on two different Chrome Windows (like 200 tabs in one and 100 tabs in another). But instead of 300 connections, I got stuck at 256 connections. Thought it was a server problem, but then I tried opening another connections from different location/same location different browser( Opera), and got more connections. Seems that Chrome browser has limit of opening up to 256 client sockets. – Valentin Goikhman May 13 '16 at 13:09

2 Answers2

0

Refer Increasing the maximum number of tcp/ip connections in linux

In my opinion,by doing sysctl net.core.somaxconn=1024 will increase limit of concurrent connections.

Community
  • 1
  • 1
0

Note sure about nodejs way, if your requirement is to server 250 plus resource at a time. Do run multiple instance of your nodejs program with different ports say 9871,9872,9873 etc and then configure apache or nginx listening on port 978 upfront and proxy the hits to underlying nodejs ports.

RMDS
  • 409
  • 1
  • 4
  • 6