stomp-js / ng2-stompjs

Angular 6 and 7 - Stomp service over Websockets
https://stomp-js.github.io/
Apache License 2.0
182 stars 32 forks source link

Client stops sending heart beat outgoing packets #248

Closed kris-g closed 2 years ago

kris-g commented 2 years ago

I have noticed that sometimes a heart beat interval is being missed.

The debug logs don't seem to indicate any problems, the PING messages simply stop. The heart beat interval is 20secs and so the TTL of 40secs on my broker is missed eventually and a disconnect message sent to the client and received. So it seems the web socket connection is still stable.

I have tried setting a log point on the client interval code which sends the heart beat and it seems it simply stop emitting for some reason.

It may be related but this is an Angular 11 app running embedded inside an iframe.

The problem has been observed using Chrome, Edge and Electron based browsers.

kris-g commented 2 years ago

Debug log output attached showing connection established, pings sent and then eventually disconnect from broker due to heart beat not being sent for the TTL period... ng2-stompjs-debug.log

kris-g commented 2 years ago

Screenshot better shows the timing of heart beat messages... image

kris-g commented 2 years ago

My config class... ` export const StwStompConfig: InjectableRxStompConfig = { // Which server? brokerURL: environment.apiWs,

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

// Wait in milliseconds before attempting auto reconnect // Set to 0 to disable // Typical value 500 (500 milli seconds) reconnectDelay: 10000,

discardWebsocketOnCommFailure: true,

// Will log diagnostics on console // It can be quite verbose, not recommended in production // Skip this key to stop logging to console debug: (msg: string): void => { console.log(msg); } }; `

kum-deepak commented 2 years ago

Please check if you are impacted by https://github.com/stomp-js/stompjs/issues/335, if yes, it is worth following the advice towards the end of the thread.

kris-g commented 2 years ago

Please check if you are impacted by stomp-js/stompjs#335, if yes, it is worth following the advice towards the end of the thread.

Spot on! I have changed heartbeat interval to 60s and the problem seems to be resolved now.

Should the default interval values be changed if Chrome is now enforcing this behaviour since Jan 2021?

kum-deepak commented 2 years ago

I think it will be a good idea. Changing the defaults and also examples and samples.