简体   繁体   中英

SignalR Azure Service Development

Ive been trying to find some more information with how the SignalR Azure service actually works, seems kind of hard to find. Anyway, I have been working on a live chat project and I have a quick question regarding developing while using the Azure SignalR service.

It seems like developing a signalR application should be done all locally. At first it was only myself working on this project and everything was going very smoothly. A couple of days ago we added some more team members to the project, one of the other developers started touching the hub I had set up. Since then it seems if I connect to the Azure Service to communicate with the hub(as opposed to hosting signalR locally), I get some strange and completely random-seeming errors while attempting to invoke any of my hub methods. I essesntially just get the "There was an error invoking Hub method 'XXX'." These errors are not even almost consistant, sometimes I successfully invoke the method, other times I do not.

The strange part of this is that my local hub does not throw any exceptions or even errors. It almost seemed as if it were unable to hit my hub all together.

Is this a product of two of us developing using the same azure service but modifying the same hub just on our different branches?

Thanks for the help!

SignalR by default doesn't give you detailed error , yo enable it right the following code:

var hubConfiguration = new HubConfiguration();
    hubConfiguration.EnableDetailedErrors = true;
    app.MapSignalR(hubConfiguration);

Then to show it in the client side

$.connection.hub.error(function (error) {
    console.log('SignalR error: ' + error)
});

Similarly you can add it in C# client code too while handling exception.

for some cases you don't even get to the client part to see the error. But by doing the first part you'll enable the Detailed Error and you can see the errors on the SignalR response. You just need a tool like Chrome Browser Web Developer Tool which gives you the Network part of the operation where all the data transfer status are logged. you can check the SignalR errors there. The information on the log will be very detailed and helpful.

For enabling log and further information on signalR error please visit https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#handleerrors

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM