autobahn-js icon indicating copy to clipboard operation
autobahn-js copied to clipboard

How can I handle error from autobahn?

Open webdev522 opened this issue 4 years ago • 5 comments

Hi,

I am using AutobahnJs lib for wamp on my browser.

how can I handle error if it occurs during connection, subscribe and other events?

I was going to handle errors from session.subscribe() The following code doesn't work.

var connection = new autobahn.Connection({
       on_user_error: function (error, customErrorMessage) {
           // here comes your custom error handling, when a 
           // something went wrong in a user defined callback.
        },
        on_internal_error: function (error, customErrorMessage) {
           // here comes your custom error handling, when a 
           // something went wrong in the autobahn core.
        }
        // ... other options
    });

There are no docs related for it.

Let me know how to do it. Any help would be appreciated.

Regards.

webdev522 avatar Oct 11 '19 14:10 webdev522

Any updates on this issue? I cannot find an handler for connection errors, which is something extremely important in my opinion.

DamiToma avatar Jan 19 '22 21:01 DamiToma

@oberstet Is there anything that can be done for a situation like this ? I'm facing the same issue as @DamiToma and @webdev522. By the way, have you guys (@DamiToma, @DamiToma) found a solution?

berTrindade avatar May 13 '23 21:05 berTrindade

@berTrindade I have not found a solution for that, however there's an onclose event which is fired when the connection is lost. I've found that to be enough for my use case.

DamiToma avatar May 16 '23 20:05 DamiToma

@DamiToma Great! Would you mind sharing how you did it ? The code perhaps.

berTrindade avatar May 17 '23 11:05 berTrindade

@berTrindade The Connection object has a onclose property.

this.connection = new autobahn.Connection({
   ...
});

this.connection.onclose = (reason, details) => {
  
};

DamiToma avatar May 22 '23 09:05 DamiToma