Websocket Connection limit how to set ?

Posted May 7, 2021 2k views
ApacheNode.jsJavaUbuntu 18.04

Hi there,
I programmed a WebSocket server in Java, with the Javax WebSocket library
My operating systems are local Windows 10, Cloud Server on Ubuntu, Web Server Apache2 + Tomcat
I’m doing my tests on both sides
My problem; After 256 connections, other sockets are on hold and if I open some more sockets,
the web server crashes and does not respond to any requests.
I’ve searched the internet a lot,
I applied what I saw but could not solve the problem.
I thought the problem was due to java, I tried it in nodejs (npm express-ws lib),
tested it locally, but the same problem happens after the 456 is connected.
Please I need help
I apologize for broken language.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @cihad,

I might be wrong buf if you are using Apache, you might have filled up Apache’s available workers. I think the default value was exactly 256.

You can open your Apache configuration file. In there you should see something similar to:

ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000

Increase both the ServerLimit and MaxClients options, restart Apache and see if this would solve your issue.


  • Hi KFSys,
    Web Server : Apache/2.4.29 (Ubuntu 18.04.5 LTS)

    I tried these examples a lot and could not come to a conclusion.
    Reverse proxy also available with tomcat (additional info)
    I would really apreciate if you help

    In which part should I perform the operation exactly;
    This data is not available in /etc/apache2/apache2.conf,
    Also not available in /etc/apache2/mods-enabled/mpm_prefork.conf

    Where should I look different?
    Best regards.

  • Hey KFSys,

    I added it to the prefork content of apache mods.
    because they didn’t exist, and the result is perfect.

    Thank you.

Hi @cihad,

I see you were able to resolve the issue! I’m glad to see the advice helped and thank you for sharing that the solution worked!

If you ever come to face similar issue, please feel free to use the community! We’ll always be happy to try and assist you