Search code examples
javatomcatwebsockettomcat8embedded-tomcat-8

Info: WebSocket connection closed, Code: 1006 while trying to run websocket samples


I've embedded tomcat 8.0.20 and using that in my server. I build the tomcat websocket example and when I'm trying to run it in my server for all 4 examples (Echo, chat, etc..) I'm getting

Info: WebSocket connection closed, Code: 1006

In the console it prints something like (url is correct per sample)

WebSocket connection to 'ws://localhost:9763/examples/websocket/echoProgrammatic' failed: Error during WebSocket handshake: Unexpected response code: 302

When I deploy this on tomcat it shows 404 error instead of 302.

Can someone tell me what could be the reason for this?

In the pom, my dependency is as follows

 <dependency>
     <groupId>javax.websocket</groupId>
     <artifactId>javax.websocket-api</artifactId>
     <version>1.0</version>
     <scope>provided</scope>
 </dependency>

It seems that websocket implementations are not get deployed correctly. Can somebody help?


Solution

  • This was totally a mistake. In the tomcat example all the URLS are hard coded with examples but my context is example(without s). That was a mistake.