I'm connecting to the server using a JS client using the stompjs lib.
If I set heartbeat parameters in the connection settings they seem to get sent correctly to the server, but they are ignored. This is the connection log:
[STOMP TRACE] >>> CONNECT
userAgent:"melis-ts-api/0.0.1"
locale:en
currency:USD
accept-version:1.0,1.1,1.2
heart-beat:5000,5000
[STOMP TRACE] <<< CONNECTED
version:1.2
heart-beat:0,0
Checking some stackoverflow questions it seems like the heartbeat is correctly handled only with an external broker and it doesn't work with the simple broker.
If this is the case I think it should be correctly stated in the documentation, otherwise it would be useful to understand if there is a workaround to make them work correctly as expected.
Comment From: rstoyanchev
Have you set a TaskScheduler
as mentioned in the docs?
Comment From: Polve
No, even after looking closely, I was able to elude the explanation: sorry and thank for the pointer.
Anyway I've a question: this seems to completely ignore the client settings overwriting the chosen settings, is this by design?
How to honor the client setting instead?
Comment From: simonbasle
If a TaskScheduler
is set, on the Spring side of things the heartbeat configuration becomes 10 000, 10 000
by default, indicating to the client that the server is capable of sending heartbeat at most every 10sec, and doesn't want more than one heartbeat every 10sec. If the client is configured with smaller heartbeats (eg. 500,500) then the session should be negotiated to send heartbeats every 10sec, not 500ms (as per the STOMP spec)
Note that the SimpleBrokerMessageHandler
can schedule a HeartbeatTask
that runs more often than the negotiated heartbeat: it runs often enough to honor the minimum interval of the server's configuration (capable server heartbeat vs desired client heartbeat). Nonetheless, it triggers heartbeat messages as per the CONNECT-CONNECTED negotiation.