Ryan
Ryan

Reputation: 5546

SignalR returns error - but how to find what it means $.connection.hub.error(function (err)

The following alert is fired in my app, but JSON.stringify(err) is always "". Is there any way for me to understand what is triggering this exception?

            $.connection.hub.error(function (err) {
                alert("Error signalR:" + JSON.stringify(err));
            });

Upvotes: 1

Views: 1988

Answers (2)

BernardV
BernardV

Reputation: 1768

I'm using SignalR 2.2.0 and don't have this problem with the same code as yours and with logging = false.

Alternatively, you can access the error message with:

$.connection.hub.lastError

Upvotes: 0

Tim B James
Tim B James

Reputation: 20364

If you set the built in SignalR debuging to true, then it should give you some additional information in the browser console.

e.g.

$.connection.hub.logging = true;

Also I would use Google Chrome or FireFox when debuging and add the error to the console via:

$.connection.hub.error(function(err){
    console.log(err);
});

Note though that this will break the code in other browsers that do not support console.log(); So you might want to take this a step further and use a custom log function. Take a look at Paul Irish's log() plugin which gives you a cross browser log function.

Upvotes: 1

Related Questions