I am following this tutorial to establish a WebSocket connection between java server and javascript client but I am facing below-mentioned error on the browser end
WebSocket connection to 'ws://localhost:8080/ws/echo' failed: Error during WebSocket handshake: Unexpected response code: 404
I am using tomcat 7.0.42 for Liferay and javax.websocket 1.1 jar
What I have tried :
- changing scope of javax.websocket jar to provided - same error
- using tomcat7.websocket - this cause my server to break down completely
PS: Some have suggested using tomcat 7.0.47 or above but I cant change the server for existing application this has to be done on tomcat 7.0.42
EchoServerclass is being loaded? Maybe try to put in a default constructor with a printout and see if it's being loaded at all? Again, the server will only 404 if it can't find the resource. Also, your URL doesn't match what I see in the tutorial, which is usingws://localhost:8080/EchoChamber/echoin the comments of the EchoServer. With most app servers, the first part is the deployment name (the JAR/WAR name), so in your example your JAR/WAR would be something likews.jarorws.war. - CodeChimp/ws/only if you define in your endpoint path or it's in your context root. It is not related to your package. The URL should bews://localhost:8080/{context root if any}/echo. If your context root is empty (ie your "welcome page" ishttp://localhost:8080/), thenws://localhost:8080/echois enough. If your context root isEchoChamber, your welcome page ishttp://localhost:8080/EchoChamber/then your websocket URI isws://localhost:8080/EchoChamber/echo- Al-un