springwebsocketstompspring-4spring-websocket

Spring 4 websocket without STOMP,socketjs


I am trying to test websocket without using socketjs library and also i don't want to add any stomp connection.

I am following the example from stackoverflow question: WebSocket with Sockjs & Spring 4 but without Stomp

So without stomp server , I have succeeded to connect via socketjs library with a url : ws://localhost:8080/greeting/741/0tb5jpyi/websocket

And now I want to remove the socketjs library to allow raw websocket connection(may be devices such as android,ios, etc...)

When I remove the parameter : .withSockJS(), I couldn't connect via websocket.

I tried the following URLs, but they didn't work:

ws://localhost:8080/greeting/394/0d7xi9e1/websocket not worked
ws://localhost:8080/greeting/websocket not worked
ws://localhost:8080/greeting/ not worked 

which URL should i use to connect ?


Solution

  • You should use ws://localhost:8080/greeting:

    new WebSocket('ws://localhost:8080/greeting')