rsocket / rsocket-js

JavaScript implementation of RSocket

Home Page:https://github.com/rsocket/rsocket-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error code not available when rsocket connection establishment fails

akulkarni-01 opened this issue · comments

What is the recommended approach to access the error code when rsocket connection establishment fails ?
The error code will help determine the user experience .

Attached is the screenshot while debugging ,the error object does not have any information about the error code in _this.handleError

Screen Shot 2020-12-01 at 4 00 34 PM

@akulkarni-01
In general, you should be able to observe initial connection setup termination via the following API

    client.connect()
        .then(rsocket => {
            // do on connected
        }, error => {
            // do on failure
            console.error(error)
        });

But, what you mentioned is something different. I believe that it is not always possible to get error or full error info due to the browser websocket API limitations and in general websocket API limitations https://stackoverflow.com/a/18804298/4891253

Thanks @OlegDokuka
So if I am understanding it correctly it is a current limitation of the ws library that rsocket JS uses .
If that correct ?

"ws": "^7.4.1"

@akulkarni-01 we use a standard websocket api available at all the browsers. Behaviors may differ depends on the browser implementation

@akulkarni-01 for more information on the browser websocket specification please use the following link -> https://html.spec.whatwg.org/multipage/web-sockets.html#the-websocket-interface. According to the spec, the onerror event handler propagates an error as ErrorEvent. And according to the spec, fields like message or error may or may not be set. Hence, we can nothing to do with that and the behavior depends on the particular browser implementation. We do not use any external libraries for the websocket-client-transport (used for the browser side) and only for nodejs side websocket-server-transport relies on the Node WebSocket library.

Also, please see -> https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event