Skip to content Skip to sidebar Skip to footer

Websocket Application Doesn't Work Properly When Deployed On Tomcat8 Server

The Problem I'm trying to run this example with minimal changes in the source code: https://spring.io/guides/gs/messaging-stomp-websocket/ I have managed to run it using Eclipse an

Solution 1:

So basically what may be happening is that once you deploy to service all your paths are a little off, so lets say you have link that says <a href="/home" > home </a> it will work on local but will not work on server because your application URL is now host:8080/appName/ and when you refer to anything with /home instead of taking you to host:8080/appName/home it will take you to host:8080/home, at which point its a broken url. So I think you can fix your issue by changing your /hello in here

functionconnect() {
            var socket = newSockJS('hello');
            stompClient = Stomp.over(socket);            
            stompClient.connect({}, function(frame) {
                setConnected(true);
                console.log('Connected: ' + frame);
                stompClient.subscribe('/topic/greetings', function(greeting){
                    showGreeting(JSON.parse(greeting.body).content);
                });
            });
        }

Solution 2:

I tried spring guides example it works perfectly fine with Google chrome Version 54.0.2840.100 (64-bit)

Link : https://github.com/spring-guides/gs-messaging-stomp-websocket/tree/master/complete

when I saw quickly I found you missing below dependencies

<dependency><groupId>org.webjars</groupId><artifactId>webjars-locator</artifactId></dependency><dependency><groupId>org.webjars</groupId><artifactId>sockjs-client</artifactId><version>1.0.2</version></dependency><dependency><groupId>org.webjars</groupId><artifactId>stomp-websocket</artifactId><version>2.3.3</version></dependency><dependency><groupId>org.webjars</groupId><artifactId>bootstrap</artifactId><version>3.3.7</version></dependency><dependency><groupId>org.webjars</groupId><artifactId>jquery</artifactId><version>3.1.0</version></dependency>

Post a Comment for "Websocket Application Doesn't Work Properly When Deployed On Tomcat8 Server"