stompjs icon indicating copy to clipboard operation
stompjs copied to clipboard

TypeError: Cannot read property 'publish' of undefined when app goes on background for long

Open Globewyze1 opened this issue 3 years ago • 1 comments

Getting error on publish when user send message after long time stying on the background. What could be the reason

if (stompClientState) { stompClientState.publish({ destination: "/app/subscribeUser", headers: { 'content-type': "application/json;charset=UTF-8" }, body: JSON.stringify(messageObj) });

}

Globewyze1 avatar Feb 21 '23 11:02 Globewyze1

The underlying connection may drop for various reasons, and the library will reconnect. However, occasionally, there may be no underlying connection. When using this library, you need to check, before operations, if there is an active broker connection.

If you find it complicated, the wrapper @stopm/rx-stomp hides this complexity among other goodies.

kum-deepak avatar Feb 22 '23 08:02 kum-deepak