Shashank Vivek
Shashank Vivek

Reputation: 17504

websocket code not working on Prod Tomcat Server - 404 Error

I am trying to run my first websocket app and refered this link to get some sample code . I simply created CustomEndPoint , WSClient class , html file and then ran it on netbeans IDE and it was working like a charm.

I tried to deploy it on tomcat server whose url is accessible using https by changing ws:// with wss:// and it worked on my dev environment but when I deployed the same code on Production env its throwing below error in console:

WebSocket connection to 'wss://xxxxxx-xxx.xxxx.com/websoc/ratesrv' failed: Error during WebSocket handshake: Unexpected response code: 404

For dev environment I below WS call is working :

wsocket = new WebSocket("wss://dev_ip:8443/websoc/ratesrv");

For Prod I am using(note the .com in url):

wss://xxxxx-xxxxx.xx.com/websoc/ratesrv

Do I need to explicitly provide the port number as well in PROD ?

Upvotes: 0

Views: 1248

Answers (2)

Waleed Abdalmajeed
Waleed Abdalmajeed

Reputation: 834

Try to use the latest version of tomcat. tomcat8.5.20 worked for me.

Upvotes: 0

Marco A. Hernandez
Marco A. Hernandez

Reputation: 821

Does your Tomcat version includes Websockets Runtime?

  • If it does you must delete all the Websockets dependencies from your WAR. Ensure that you call mvn clean after change scope to provided.

  • If not, you should include it. If you want to use Tyrus just put

<dependency>
    <groupId>org.glassfish.tyrus</groupId>
    <artifactId>tyrus-container-servlet</artifactId>
    <version>1.12</version>
</dependency>

<dependency>
    <groupId>org.glassfish.tyrus</groupId>
    <artifactId>tyrus-client</artifactId>
    <version>1.12</version>
</dependency>

And check that that there are no errors in the Tomcat console when deploy.

Upvotes: 1

Related Questions