3

Now I'm using stomp to connect from web to server.

I know STOMP has a heartbeat mechanism after v1.1, also I've already set it successfully. But I don't know how to detect/catch PING/PONG frame and handle it.

The code in web like this:

    this.stomp = Stomp.client(this.wsUrl);
    this.stomp.heartbeat.outgoing = 5000;
    this.stomp.heartbeat.incoming = 5000;
    this.stomp.connect({}, (frame: any) => {
    // ...
    }, (error: any) => {
    // ...
    });

The code in server like this. we use spring stomp.

    public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic")
            .setTaskScheduler(new DefaultManagedTaskScheduler())
            .setHeartbeatValue(new long[] {5000, 5000});
    config.setApplicationDestinationPrefixes("/signal");
}

I can see PING/PONG frame printed in the console panel in chrome.

Ruochen Xu
  • 96
  • 1
  • 7
  • did you find any solution for your question? I am also facing same problem in my project? I can't understand how to use it in spring? – Amit Nov 19 '17 at 11:59
  • No, I am still sending heartbeat by myself. – Ruochen Xu Nov 21 '17 at 01:01
  • You are sending it yourself? I thought the libraries are sending it? What do you want to do with the ping/pong frame? – Basil Jan 15 '18 at 20:15
  • I expect it can automatically disconnect or reconnect according to my configuration. But it does nothing but send a ping/ping message. Even I don't know how to write trigger about the message. – Ruochen Xu Jan 16 '18 at 07:19
  • Hi. Did you find a solution by any chance? I'm stuck at the same problem. Ping messages are being sent but I don't know how to handle timeout. – Ju Bc Jun 07 '21 at 17:08

0 Answers0