HTML5 websockets: max number of open connections?

Solution 1:

There isn't a standard specification of max-connections default value for browsers.It depends on implementation [0]. Furthermore using more than a web-socket per browsing session for the same application seems overkill since you can use pub/sub channels.

Bottleneck for connections usually is at server side. Web-socket is a upgrade to HTTP so connections are "just" upgraded HTTP(TCP) connections [1].HTTPS and WSS add just a security layer to the normal connection.They are not a different connection [2]. In your case check maxConnections (and maxThreads) [3] and your Operating System maximums [4][5]. If your concurrent connections reach tens of thousands maybe you should start thinking on load balancing or clustering [6].

[0]https://code.google.com/p/chromium/issues/detail?id=85323

[1]http://en.wikipedia.org/wiki/WebSocket

[2]http://en.wikipedia.org/wiki/HTTP_Secure

[3]http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

[4]https://serverfault.com/questions/10852/what-limits-the-maximum-number-of-connections-on-a-linux-server

[5]https://superuser.com/questions/251596/is-there-a-hard-limit-of-65536-open-tcp-connections-per-ip-address-on-linux

[6]http://tomcat.apache.org/tomcat-7.0-doc/config/cluster.html

More about high concurrency: http://www.kegel.com/c10k.html

Solution 2:

In Gecko 7 they introduced the aprameter network.websocket.max-connections you can set it in about:config. It's setting the maximum websocket connections "at a time" according to this: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

I don't know if you can determine this number from the code and if there is any way to determin how many is open in other sessions (so how many you have left).