title: How to fix websockets which are giving a NetworkError: 400 Unsupported draft specification: 13
body: <p>I'm trying to use an example from <a href="http://webtide.intalio.com/2011/08/websocket-example-server-client-and-loadtest/" rel="nofollow">this website</a> in order to learn how to use web-socket in jetty. I'm using maven to gather dependencies.</p>
  
  <p>When I open the page in localhost:8082, the page appears(it's a chat client), however if I try to login(which is when web-sockets are used first) nothing happens. Using Firebug, I determined that the error messages I get are as follows:</p>
  
  <pre><code>"NetworkError: 400 Unsupported draft specification: 13 - http://localhost:8082/chat"
  </code></pre>
  
  <p>and also</p>
  
  <pre><code>Firefox can't establish a connection to the server at ws://localhost:8082/chat
  </code></pre>
  
  <p>I checked the jar(version 7.5.0.RC1) for web sockets and it turns out that the WebSocketFactory does not support Sec-WebSocket-Draft 13.</p>
  
  <p>I updated the jars to the latest version(8.0.3.v20111011), which does support version 13:</p>
  
  <pre><code>    switch (draft)
      {
          case -1:
          case 0:
              extensions=Collections.emptyList();
              connection = new WebSocketConnectionD00(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol);
              break;
          case 1:
          case 2:
          case 3:
          case 4:
          case 5:
          case 6: 
              extensions=Collections.emptyList();
              connection = new WebSocketConnectionD06(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol);
              break;
          case 7:
          case 8:
              extensions= initExtensions(extensions_requested,8-WebSocketConnectionD08.OP_EXT_DATA, 16-WebSocketConnectionD08.OP_EXT_CTRL,3);
              connection = new WebSocketConnectionD08(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft);
              break;
          case 13:
              extensions= initExtensions(extensions_requested,8-WebSocketConnectionD13.OP_EXT_DATA, 16-WebSocketConnectionD13.OP_EXT_CTRL,3);
              connection = new WebSocketConnectionD13(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft);
              break;
          default:
              LOG.warn("Unsupported Websocket version: "+draft);
              response.setHeader("Sec-WebSocket-Version","0,6,8,13");
              throw new HttpException(400, "Unsupported draft specification: " + draft);
      }
  </code></pre>
  
  <p><br />
  ...but I still get the same error. On top of that, I now get errors in the code, saying that the constructor WebSocketClient() is deprecated and that a number of methods I was using don't exist in WebSocketClient.</p>
  
  <p>So I guess my questions are: </p>
  
  <p>1) What is causing this to run version 13 and how can I get it to use version 8?<br />
  2) Has anybody else tried to use this tutorial and had trouble?<br />
  3) Is there an easier way to learn websockets(maybe this example is out of date already)?<br /></p>
  
  <p>Thanks for any help.</p>