-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How not to use SockJS #14
Comments
Just wondering... why would you even want to do this? SockJS is only an abstraction layer that lets you create a persistent connection to the server without having to care about the actual transport protocol being used. If you don't use SockJS, you'll then need to write your own logic (both server and client) to determine if websockets is supported and if not, what fallbacks are available. Having had to do that before, it's no fun. I'd be interested to find out why you would want to forgo using SockJS. |
Right now - because I want to experiment with all options - no sockjs, no stompjs, spring, javax.websocket, etc. For a regular application you are right. My only concern is that it is yet-another-dependency, but that's rarely an issue, I agree. |
Have you tried turning off SockJS support in the configuration? i.e. removing BTW you can also connect to a raw WebSocket (i.e. no SockJS frames) even with SockJS (i.e Also for what it's worth on the server-side at least using SockJS doesn't require any new dependencies. |
To summarize, to remove the SockJS layer, remove |
It sounds very unusual. Is it possible to create a simple example some place that demonstrates the issue? |
All I needed was remove
by
why, would I do that? wellI have 2 reasons:
|
In Spring 4.2, just use the Something like:
|
Indeed, and the chapter in the reference documentation is organized starting with a sub-section on WebSocket followed by SockJS and then STOMP. |
7455 |
i can not understand your mean! |
I had the same issue with OP. The scenario is that I tried to connect to spring websocket from iOS, however I didn't find any usable Stomp library that supports sockjs. So I tried to use Stomp without sockjs. Per the documentation https://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-intro.
I removed the with-sockjs line from my configuration and tested the above code in chrome dev tools. However it didn't work. The error is URL invalid. Then I used the URL "ws://domain/spring-websocket-portfolio/portfolio", it then gave me 400 Bad Request. So without sockjs, which url should I connect to? |
Removing .withSockJS()
|
The same.
Old server version perhaps? |
I use SpringBoot 1.5.2 with tomcat starter. I'm try to figure out why this happens : link |
That links shows a different error than the "RequestUpgradStrategy not found". |
@rstoyanchev it's not working for me. I tried:
It gave the error:
while if I tried
It then gave the error
|
If SockJS is turned off there is no point in trying Well 400 means bad input. Look further. Response headers, DEBUG logging for |
this answer: Spring boot Websocket without SockJS @Override
public void registerStompEndpoints(StompEndpointRegistry registry)
{
// This will allow you to use ws://localhost:8080/test to establish websocket connection
registry.addEndpoint("/test");
// This will allow you to use http://localhost:8080/test to establish websocket connection
registry.addEndpoint("/test").withSockJS();
} |
I don't need to use SockJS - I would just like to use a regular websocket. Stomp provides: Stomp.client("ws://:/endpoint"). However, that doesn't seem to work with this example. Can it work, and how to make it work like that.
Probably it would be nice ot have a page without SockJS.
The text was updated successfully, but these errors were encountered: