webstomp-client icon indicating copy to clipboard operation
webstomp-client copied to clipboard

Error frame confusion

Open rocketraman opened this issue 9 years ago • 4 comments

It looks like when an error frame is received, it is always handled by the connect error callback.

For example:

  1. CONNECT -- server returns success
  2. SUBSCRIBE -- server returns error response e.g. permission denied
  3. client calls CONNECT error callback

This is pretty confusing and hard to program against -- one would expect some sort of error callback related to the SUBSCRIBE for step 2 and 3.

rocketraman avatar Sep 14 '16 14:09 rocketraman

I do agree. I forked previous stomp lib with all pending PR + re-write it in es6 with no major evolution to not break the API a lot. Now I would like to launch a future major release with a lot of enhancement + some test sbut I really need some free time to do it or some PRs to help me.

JSteunou avatar Sep 15 '16 08:09 JSteunou

Actually, I think it is expected behavior. Because STOMP doesn't declare how to handle ERROR frames, and that's why src/client.js:136 allow a user to decide how to handle it properly. I agree that errorCallback is a bit confusing name, but I can't imagine better.

Also, remember that adding special heads require additional server-side enhancement(which most of the time is too hard).

Mamoru1234 avatar Mar 02 '17 16:03 Mamoru1234

I agree that errorCallback is a bit confusing name, but I can't imagine better.

What's confusing is not the name of the callback, but where it is passed in. It is passed in to the connect method, but is also called as a result of other operations like subscribe.

If there is no way for the client to distinguish between a connect and a subscribe error (which seems to be the case), then the error callback should be configured at the client level i.e. before calling connect.

rocketraman avatar Mar 02 '17 17:03 rocketraman

@rocketraman There is no way to distinguish ERROR frames. I think it's good idea to have 1 global errorHandler per Client instance.

Mamoru1234 avatar Mar 02 '17 17:03 Mamoru1234