Affects: 5.3.10
When subscribing to SessionSubscribeEvent and in handler sending message back to this user only using convertAndSendToUser, it is not sent to the channel. Code worked fine in versions 5.2.x. But after rewrite DefaultSubscriptionRegistry seems to stop working.
Example of handler:
@EventListener private void handleSessionSubscribeEvent(SessionSubscribeEvent event) {
String sessionId = (String) event.getMessage().getHeaders().get("simpSessionId");
SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
headerAccessor.setSessionId(sessionId);
headerAccessor.setLeaveMutable(true);
tpl.convertAndSendToUser(sessionId, "/auctions/final", "Something changed at " + LocalDateTime.now(),
headerAccessor.getMessageHeaders());
}
Config is following:
@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/websocket").withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/topic", "/queue", "/user", "/auctions");
registry.setApplicationDestinationPrefixes("/app");
}
}
Example project can be found here: https://github.com/vitali-kviatkouski/spring-websocket-subscription
Comment From: n0ise9914
I've figured out the problem is with subscription not sending the message
As you can see in spring-messaging version of 5.2.6 the method findSubscriptions is returning the subscription as well
Look at the same code after updating the spring to version 5.3.13
As you can see, it can't find the subscription to send the message to
The same code with spring 5.3.13 is also working well (the subscription is registered) when the username is specified in subscription /user/admin/topic/tracker
Again, the same code with spring 5.3.13, but without username in destination isn't working because the destinationCache is empty (not filled lately)
I think there is something wrong with the destination translator which is caused destinationCache to not get filled, so the subscription is not registered and the convertAndSendToUser is failed because there is no subscription to route the message to
It's also possible to modify the subscriptionRegistry to force the subscription, but is it really a framework ralated issue?
Any HELP?
Comment From: tomaszbadon
Hi there,
What is happening with this Bug?
I haven't seen any PR for this, but I encountered this issue in my app.
Thank you a lot.
BR,
Comment From: maanasa
Hi, I have the same problem. Will this be fixed anytime soon?
Comment From: spsheni
Hi, Any updates on fix for this issue?
Comment From: tomaszbadon
This what I can recommend to copy-paste the fix in you project locally. It works for me.
Comment From: snicoll
@vitali-kviatkouski I've looked at your sample and I don't understand how I am supposed to use it.
Code worked fine in versions 5.2.x.
I did downgrade to 5.2.x
to understand what changed but I couldn't find anything. In both cases, sending a message doesn't do anything for me. Can you please clarify as having a sample is the best way to make progress on this issue.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.