Reputation: 257
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?
Upvotes: 5
Views: 4454
Reputation: 642
Looks like the limit for chromium is set to 256 per the discussion below:
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.
Upvotes: 1
Reputation: 856
Try to open new tabs with your stress test manually or with window.open
in code.
Upvotes: 2