spring-guides / gs-messaging-stomp-websocket

Using WebSocket to build an interactive web application :: Learn how to the send and receive messages between a browser and the server over a WebSocket

Home Page:http://spring.io/guides/gs/messaging-stomp-websocket/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Whoops! Lost connection to undefined

soumasish opened this issue · comments

This problem is turning out to be my nemesis. So I did implemented Spring web sockets into an application, following the instructions mentioned here,
https://github.com/rstoyanchev/spring-websocket-portfolio

So when I first tried to run the app using the embedded tomcat that came along with Spring boot it worked fine. Then started the litany of problems. So I tried to the run the application inside a local instance of Tomcat. The moment I click the connect button, it would try to access,

http://localhost:8080/my-project-root/info
and end up with
Whoops! Lost connection to undefined

I managed to resolve the issue by adding the following to my gradle.build

providedCompile "javax.servlet:servlet-api:2.5"
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'

And the following to my Application.Java class

public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(applicationClass, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(applicationClass);
    }


    private static Class<Application> applicationClass = Application.class;
}

Now I want to deploy a war file on my local Tomcat instance. So i ran gradlew build on the command line and created a war and copied this to the webapps directory of my tomcat instance.
Now when  I start tomcat and open up the default page and click connect I'm back to the same problem.
` http://localhost:8080/my-project-root/info`
`Whoops! Lost connection to undefined`
 I'd really appreciate some help with this. Also understand what am I doing wrong/not doing with the configuration that's causing this.

I'm afraid this question is not related to that guide.
Could you create a StackOverflow question (and ping us here?).

We'll need more information to help you, such as your build.gradle file, some logs (provided org.springframework.web.socket is at DEBUG level), the actual HTTP request/response information you'll find in your browser network tab and of course the information you already provided.

Thanks!