0

I'm trying to make this example work

But when I deploy the war file to Tomcat and start it, the connection cannot be established.

In browser console I see that the client tries to connect to http://localhost:8080/Spring4WebSocket/add/info and receives 404, though the specified in start.jsp URL for connecting is /Spring4WebSocket/add (without that "/info" part in the end).

Why is this strange "/info" suffix added to the url and what can I do to change this and make this example work fine?

This solution wasn't helpful for me: SockJs - 'info' path not found

Community
  • 1
  • 1
Green Fireman
  • 617
  • 1
  • 11
  • 27

1 Answers1

0

The /info URL is called by SockJS (see docs):

...before the client starts the session. It's used to check server capabilities (websocket support, cookies requirement) and to get the value of "origin" setting (currently not used).

I looked at the example you are following and I don't see anything wrong with it. It follows closely a Spring guide: Using WebSocket to build an interactive web application so it should work.

Just one question though. Did you exactly follow the instructions or downloaded the zip file from the page or did you create it on your own? You get that error on the first SockJS request here:

var socket = new SockJS('/Spring4WebSocket/add');

Is your application also called Spring4WebSocket or something else? If it's called something else then use that instead:

var socket = new SockJS('/YourAppNameGoesHere/add');
Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • Yeah, it was the first thing I checked. My application is called exactly like that. Thanks for your answer anyway. – Green Fireman May 25 '15 at 08:33
  • @user2246018: I've downloaded and install the project that comes with the link you posted and it works without issues. Did you check your code against it? Are there any differences? Does your `WebAppInitializer.onStartup` method get called to load the Spring context? – Bogdan May 25 '15 at 20:23