title: Websocket allows only 200 connections
body: <p>I just implemented a simple Websocket system on my server. I am trying to test the maximum number of connections, I made the following code:</p>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>for(var i=0; i&lt;300; i++){
      websocket();
  }
  
  function websocket() {
      var wsUri = "ws://" + document.location.host + document.location.pathname + "websocket";
      var ws = new WebSocket(wsUri);
      ws.onopen = function () { ws.send("User connected"); };
      ws.onmessage = function (e) { writeToPage(e.data); };
      ws.onclose = function () { writeToPage("User disconnected"); };
  }
  </code></pre>
  
  <p>Everytime I run it, first 200 users gets connected, after that, all requests have their onclose() called. In web console I get the following errors:</p>
  
  <p><strong>Mozilla:</strong> <em>The connection to ws://localhost:8080/MyApp/websocket was interrupted while the page was loading</em></p>
  
  <p><strong>Chrome:</strong> <em>Error during WebSocket handshake: 'Connection' header value is not 'Upgrade': upgrade close</em></p>
  
  <p>My web application is deployed on <code>Tomcat 7.0.52</code>. I read that by default it only allows 200 threads, so I added <code>maxThreads="1000"</code> in <code>conf/server.xml</code> to both <code>Connector</code> and <code>Executor</code> but the result is the same.</p>
  
  <p>in <strong>web.xml</strong> I added:</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;org.apache.tomcat.websocket.executorMaxSize&lt;/param-name&gt;
      &lt;param-value&gt;1000&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>I tried opening 300 websockets with <code>ws://echo.websocket.org</code>, and again only 200 worked.</p>
  
  <p>Is this the maximum number of connections my server allows? 
  Is this the maximum number of websockets I can create as client? 
  Is this a good way of testing heavy load?
  How can I increase the number?</p>