stomp-js / stomp-websocket

Stomp client for Web browsers and node.js apps
https://stomp-js.github.io/stomp-websocket/
Apache License 2.0
141 stars 36 forks source link

Catching error on susbcribing to a non existing destination? #48

Closed aalbericio closed 5 years ago

aalbericio commented 5 years ago

Hello,

I'm using the latest version of the library (4.0.8) and I'm trying to find a way to "catch" the error when subscribing to a non existing destination:

client.subscribe('foobar')

Since 'foobar' does not exist as a real stomp destination on the server, stompjs unsubscribes from all already subscribed (and working) subscriptions.

When I try to subscribe to a non existing destination, I'd like stompjs to just throw some kind of catchable error but keep the connection and the working subscriptions alive.

Is this possible? Am I doing something wrong?

Thank you.

kum-deepak commented 5 years ago

The STOMP standards specify that on any ERROR, the broker is supposed to send an ERROR frame and close the connection.

So, a complaint broker is likely to follow this and close the connection if there is an error during subscription because destination does not exist. Actual behavior may vary by the specific broker in use.

So, check the log output and see if after attempting to subscribe non existent destination, if it drops the connection and reconnects.

aalbericio commented 5 years ago

Sorry Deepak,

We had a reactive chain defined that effectively closed the connection on error. It's not a StompJS issue.

I close the issue.