stomp-js / rx-stomp

STOMP adaptor for RxJS
Apache License 2.0
111 stars 21 forks source link

RxStomp client doesn`t receive heartbeat messages. #488

Closed inzagher closed 1 year ago

inzagher commented 1 year ago

In my angular project i use rx-stomp client with both heartbeat parameters set. But server does not send heartbeat message. If i use stompjs, server sends heartbeat messages every 25 seconds. Is it bug, or rx-stomp client configuration settings are wrong?

RxConfig:
{
    brokerURL: 'ws://some-websocket-url',
    connectHeaders: { username: userName },
    heartbeatIncoming: 15000,
    heartbeatOutgoing: 15000,
    reconnectDelay: 30000,
    connectionTimeout: 5000
};

"@angular/core": "^14.2.5", "@stomp/rx-stomp": "^1.2.0"

davideas commented 1 year ago

Hello there, it works, I'm using it.

I use Spring at server side:

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.setApplicationDestinationPrefixes("/stomp");
    config.enableSimpleBroker("/topic", "/queue")
            .setHeartbeatValue(new long[]{20000, 20000}) // 20 seconds Ping-Pong
            .setTaskScheduler(new DefaultManagedTaskScheduler());
}

Then, in Typescript they should match. Do some tests by modifing all values.

// How often to heartbeat?
// Interval in milliseconds, set to 0 to disable
heartbeatIncoming: 20000, // Typical value 0 - disabled
heartbeatOutgoing: 20000, // Typical value 20000 - every 20 seconds
inzagher commented 1 year ago

Hello. I'm using spring boot server too, without scheduler and heartbeat settings. When I set these values, typescript client sends and receives heartbeat messages. Websocket connection uses server side settings, client settings are ignored. This is exactly what I'm looking for. Thanks a lot!