title: WebSocket EndPoint not getting resolved: Error Code: 404
body: <p>I am trying to create a very basic web-socket application. steps followed:</p>
  <ol>
  <li>Created EchoServer java class</li>
  </ol>
  <pre><code>    import javax.websocket.OnMessage;
      import javax.websocket.server.ServerEndpoint;
      
      @ServerEndpoint(&quot;/echo&quot;)
      public class EchoServer {
      
          @OnMessage
          public String echo(String incomingMessage) {
              return &quot;I got this (&quot; + incomingMessage + &quot;) so I am sending it back&quot;;
          }
      }
  </code></pre>
  <ol start="2">
  <li><p>Created html with javascript calling the above endpoint</p>
    
  <pre><code> &lt;html&gt;
   &lt;head&gt;
       &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
       &lt;title&gt;Web Socket JavaScript Echo Client&lt;/title&gt;
       &lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
           var echo_websocket;
           function init() {
               output = document.getElementById(&quot;output&quot;);
           }
           function send_echo() {
               var wsUri = &quot;ws://localhost:7003/wspractice/echo&quot;;
               writeToScreen(&quot;Connecting to &quot; + wsUri);
               echo_websocket = new WebSocket(wsUri);
               echo_websocket.onopen = function (evt) {
                   writeToScreen(&quot;Connected !&quot;);
                   doSend(textID.value);
               };
               echo_websocket.onmessage = function (evt) {
                   writeToScreen(&quot;Received message: &quot; + evt.data);
                   echo_websocket.close();
               };
               echo_websocket.onerror = function (evt) {
                   writeToScreen('&lt;span style=&quot;color: red;&quot;&gt;ERROR:&lt;/span&gt; '
                       + evt.data);
                   echo_websocket.close();
               };
           }
           function doSend(message) {
               echo_websocket.send(message);
               writeToScreen(&quot;Sent message: &quot; + message);
           }
           function writeToScreen(message) {
               var pre = document.createElement(&quot;p&quot;);
               pre.style.wordWrap = &quot;break-word&quot;;
               pre.innerHTML = message;
               output.appendChild(pre);
           }
           window.addEventListener(&quot;load&quot;, init, false);
       &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
   &lt;h1&gt;Echo Server&lt;/h1&gt;
   &lt;div style=&quot;text-align: left;&quot;&gt;
       &lt;form action=&quot;&quot;&gt;
           &lt;input onclick=&quot;send_echo()&quot; value=&quot;Press to send&quot;
                  type=&quot;button&quot;&gt;
           &lt;input id=&quot;textID&quot; name=&quot;message&quot; value=&quot;Hello Web Sockets&quot;
                  type=&quot;text&quot;&gt;
           &lt;br&gt;
       &lt;/form&gt;
   &lt;/div&gt;
   &lt;div id=&quot;output&quot;&gt;&lt;/div&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  </li>
  </ol>
  <p>Deployed above project as war file (contextpath: wspractice) in WebLogic Server Version: 14.1.1.0.0 server.<br>
  <a href="https://i.stack.imgur.com/KvEk8.png" rel="nofollow noreferrer">named server configuration on weblogic(listening on port 7003)</a><br>
  <a href="https://i.stack.imgur.com/GLY7z.png" rel="nofollow noreferrer">application deployed on named server</a></p>
  <p>when trying the above html, getting &quot;WebSocket connection to 'ws://localhost:7003/wspractice/echo' failed: Error during WebSocket handshake: Unexpected response code: 404&quot; error.</p>
  <p>When I tried to access another normal jsp in WEB-INF, it is getting resolved properly but only web-socket is not getting resolved. Result is as shown in below image.<br></p>
  <p>I Understand 404 occurs when server is not able to find the service(echo in this case) but I am not getting why it occurred in this case even though &quot;echo&quot; end point is available.</p>
  <p><a href="https://i.stack.imgur.com/Odw7C.png" rel="nofollow noreferrer">Result in browser</a>.<br>
  Tried in chrome,firefox,ie but same results.
  Please help me to understand why this is happening.</p>