I want to do some stress test against my websocket server runnig this javascript example in my browser (chrome) below:
function create_ws() {
var ws=new WebSocket("ws://127.0.0.1/");
ws.onopen=function(evt){
var binary = new Uint8Array(2);
binary[0]=1;
binary[1]=2;
ws.send(binary.buffer);
};
ws.onclose=function(evt){};
ws.onmessage=function(evt){};
ws.onerror=function(evt){};
}
var connections = [];
var numberOfconnections=100;
for(var i = 0; i < numberOfconnections; i++) {
connections.push(create_ws());
}
The problem is the script above let me run only about 100 connections at the same time. If i increase numberOfconnections
to 300 it throws following error:
WebSocket connection to 'ws://127.0.0.1/' failed: Error in connection establishment: net::ERR_INSUFFICIENT_RESOURCES
Is there a way to increase the number of websocket connections in browser?
Try to open new tabs with your stress test manually or with window.open
in code.
Looks like the limit for chromium is set to 256 per the discussion below:
Chromium Discussion
It's possible other browsers have different limits. As I only use so many connections for stress testing, I plan to open a few windows to go outside the limit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With