title: Jboss EAP 6.4 - Websocket 500 internal server error
body: <p>=== Java Console log ===</p>
  
  <pre><code>JBWEB000236: Servlet.service() for servlet default threw exception: java.lang.IllegalStateException: JBWEB000034: Cannot upgrade from HTTP/1.1 without IO events
  </code></pre>
  
  <p>=== HTML Code ===</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;body&gt;
      &lt;div&gt;
          &lt;div id="connect-container"&gt;
              &lt;div&gt;
                  &lt;fieldset&gt;
                      &lt;legend&gt;Connect or disconnect using WebSocket :&lt;/legend&gt;
                      &lt;input type="button" id="connect" onclick="connect();"
                          value="Open Connection" /&gt; &lt;input type="button" id="disconnect"
                          onclick="disconnect();" value="Close Connection" /&gt;
                  &lt;/fieldset&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;fieldset&gt;
                      &lt;legend&gt;Type your name below. then click the `Say Hello`
                          button :&lt;/legend&gt;
                      &lt;input id="name" type="text" size="40" style="width: 40%" /&gt; &lt;input
                          type="button" id="sayHello" onclick="sendMessage();"
                          value="Say Hello" disabled="disabled" /&gt;
                  &lt;/fieldset&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  Current WebSocket Connection Status:
                  &lt;output id="currentstatus" class="message"&gt;Closed&lt;/output&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;output id="hellomessage" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  
  
  <p>=== Javascript Code ===
  </p>
  
  <pre><code>var websocket = null;
  
      function connect() {
  
          var wsURI = "ws://localhost:8380/websockets-server/helloName";
          websocket = new WebSocket(wsURI);
  
          websocket.onopen = function() {
              displayStatus('Open');
              document.getElementById('sayHello').disabled = false;
              displayMessage('Connection is now open. Type a name and click Say Hello to send a message.');
          };
          websocket.onmessage = function(event) {
              // log the event                
              displayMessage('The response was received! ' + event.data,
                      'success');
          };
          websocket.onerror = function(event) {
              // log the event
              displayMessage('Error! ' + event.data, 'error');
          };
          websocket.onclose = function() {
              displayStatus('Closed');
              displayMessage('The connection was closed or timed out. Please click the Open Connection button to reconnect.');
              document.getElementById('sayHello').disabled = true;
          };
      }
  
      function disconnect() {
          if (websocket !== null) {
              websocket.close();
              websocket = null;
          }
          message.setAttribute("class", "message");
          message.value = 'WebSocket closed.';
          // log the event
      }
  
      function sendMessage() {
          if (websocket !== null) {
              var content = document.getElementById('name').value;
              websocket.send(content);
          } else {
              displayMessage(
                      'WebSocket connection is not established. Please click the Open Connection button.',
                      'error');
          }
      }
  
      function displayMessage(data, style) {
          var message = document.getElementById('hellomessage');
          message.setAttribute("class", style);
          message.value = data;
      }
  
      function displayStatus(status) {
          var currentStatus = document.getElementById('currentstatus');
          currentStatus.value = status;
      }
  </code></pre>
  
  
  
  <p>=== Java Class Code ===</p>
  
  <pre><code>package org.jboss.as.quickstarts.websocket_hello;
  
  import javax.websocket.CloseReason;
  import javax.websocket.OnClose;
  import javax.websocket.OnMessage;
  import javax.websocket.OnOpen;
  import javax.websocket.Session;
  import javax.websocket.server.ServerEndpoint;
  
  @ServerEndpoint("/helloName")
  public class HelloName {
  
     @OnMessage
     public String sayHello(String name) {
         System.out.println("Say hello to '" + name + "'");
         return ("Hello" + name);
     }
  
     @OnOpen
     public void helloOnOpen(Session session) {
         System.out.println("WebSocket opened: " + session.getId());
     }
  
     @OnClose
     public void helloOnClose(CloseReason reason) {
         System.out.println("Closing a WebSocket due to " +   reason.getReasonPhrase());
     }
  }
  </code></pre>
  
  <p>Library and XML File</p>
  
  <pre><code>WEB-INF/lib/jboss-websocket-api_1.0_spec-1.0.0.Final.jar
  WEB-INF/jboss-web.xml
  </code></pre>
  
  <p><strong>jboss-web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-web&gt;
     &lt;enable-websockets&gt;true&lt;/enable-websockets&gt;
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p><strong>Browser: Network > WS > Headers</strong></p>
  
  <p>=== General ===</p>
  
  <pre><code>Request URL:ws://localhost:8380/websockets-server/helloName
  Request Method:GET
  Status Code:500 Internal Server Error
  </code></pre>
  
  <p>=== Request Headers ===</p>
  
  <pre><code>Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:th-TH,th;q=0.8,en;q=0.6
  Cache-Control:no-cache
  Connection:Upgrade
  Cookie:JSESSIONID=b+Xfkitt-KYWiRl99vmbubUN
  Host:localhost:8380
  Origin:http://localhost:8380
  Pragma:no-cache
  Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
  Sec-WebSocket-Key:NH/fCYRMJge2+3WGz9gcLg==
  Sec-WebSocket-Version:13
  Upgrade:websocket
  User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  </code></pre>
  
  <p>=== Response Headers ===</p>
  
  <pre><code>Connection:close
  Content-Length:1885
  Content-Type:text/html;charset=utf-8
  Date:Mon, 30 Jan 2017 08:54:00 GMT
  Server:Apache-Coyote/1.1
  </code></pre>
  
  <p>=== Tab Frames ===</p>
  
  <pre><code>(Opcode -1)
  </code></pre>