Skip to content
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

Ability to send STOMP messages to particular session [SPR-12143] #16757

Closed
spring-issuemaster opened this Issue Sep 1, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Sep 1, 2014

Alex opened SPR-12143 and commented

Using SimpMessagingTemplate.convertAndSentToUser() we can asynchronously send messages to selected user, but to do it we need to use spring security and having the connected user authenticated with it.

It would be very useful to send messages to selected sessions, e.g, having a method like convertAndSendToSession(sessionId, ....), otherwise it's impossible to send messages to selected non-authenticated users, or users authenticated using a different mechanism from spring-security.


Affects: 4.1 RC2

Referenced from: commits 96563c7

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 2, 2014

Rossen Stoyanchev commented

Spring Security is not a requirement. The WebSocket session is associated with the user from the HttpServletRequest at the time of handshake (i.e. request.getUserPrincipal()).

That said if you do know the WebSocket sessionId and just want to send a message, you can use the regular convertAndSendToUser method passing the sessionId instead of a user. Take a look the present version of SendToMethodReturnValueHandler and you will see that it does exactly that if there is no user information.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 2, 2014

Alex commented

I tried that just because I saw it in the SendToMethodReturnValueHandler class, but without luck.
I tried to debug to understand why and I was not able to.

Also, my sessionIds are just sequential numbers, starting from 0 (the sessionId of the first connected user), is that normal?
The sessionId should be random so that it's not guessable, also, this way I can't distinguish the "0" user from the "0" sessionId, isn't?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 2, 2014

Rossen Stoyanchev commented

Hm, #15933 was targetting this very feature quite specifically. We have tests and the reporter also confirmed it. Could you take a look at the #15933 and also take the commit comment and changes. Is it possible that you're doing something slightly different? If you still can't make it work, can you provide a small sample, preferably through https://github.com/spring-projects/spring-framework-issues and i'll take a look.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 2, 2014

Alex commented

Since someone is able to make it work I suppose this means I'm doing something wrong.
Before reporting the problelm I would like to double check what I do: I left a message on #15933 asking details.

Any help is very appreciated.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 2, 2014

Alex commented

Thanks for the tip, I read nothing about the headers in the documentation and I could not imagine it, but now it works :)

Please close this issue as invalid, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.