I'm having trouble getting user destinations to work with Spring STOMP websockets.
I seem to have the general configuration working. For instance, the following works.
Client:
svc.stompClient.subscribe('/queue/messages', msg );
Server:
stompTemplate.convertAndSend("/queue/messages", msg);
However, when I attempt to send to a specific user destination as follows:
Client:
svc.stompClient.subscribe('/user/queue/messages', msg );
Server:
stompTemplate.convertAndSendToUser(username, "/queue/messages", msg);
... nothing seems to happen.
I have set up SessionConnectedEvent
and SessionSubscribeEvent
listeners, which show:
SessionConnectedEvent[GenericMessage [
payload=byte[0],
headers={
simpMessageType=CONNECT_ACK,
simpConnectMessage=GenericMessage [
payload=byte[0],
headers={
simpMessageType=CONNECT,
stompCommand=CONNECT,
nativeHeaders={
accept-version=[1.1,1.0],
heart-beat=[10000,10000]
},
simpSessionAttributes={},
simpSessionId=erlz0dm6
}
],
simpSessionId=erlz0dm6
}
]]
SessionSubscribeEvent[GenericMessage [
payload=byte[0],
headers={
simpMessageType=SUBSCRIBE,
stompCommand=SUBSCRIBE,
nativeHeaders={
id=[sub-0],
destination=[/user/queue/messages]
},
simpSessionAttributes={},
simpSubscriptionId=sub-0,
simpSessionId=erlz0dm6,
simpDestination=/user/queue/messages
}
]]
And on the client side, I see the following logged:
>>> SUBSCRIBE
id:sub-0
destination:/user/queue/messages
Tracing some way through the sendToUser
method, I can see that it is passing /user/myusername/queue/messages
to the destination resolver. However, nothing more is logged on the server, and the client doesn't receive the message.
So I'm keen to determine:
- Is there any debug logging that I might be able to enable, which might aid in diagnosing the issue?
- Are there any common configuration traps which I might have fallen into?
Please let me know if there is any additional information (i.e. code) that I might be able to provide to assist in diagnosing the issue. The question is already quite long, so I'm trying to avoid cluttering it with too much extraneous code.
I'm using:
- Spring Boot 1.2.1 (Same issue with 1.0.8. I upgraded to see if it might help.)
- sockjs-client 0.3.4
- stomp-websocket 2.3.1
Also, in case it is relevant, I'm using a PreAuthenticatedAuthenticationProvider
to determine the user, and a HttpServletRequestWrapper
to ensure that the username defined in the header is provided as the Principal
name. i.e. The username in the code above is my Active Directory domain user name.
Note - I have examined this question, which sounds a bit similar. However, their 'working code' is the bit that I'm trying to get working, without success.