Azure / azure-signalr

Azure SignalR Service SDK for .NET
https://aka.ms/signalr-service
MIT License
422 stars 100 forks source link

Can't track reason for "Error when processing messages." #1238

Open andrem0 opened 3 years ago

andrem0 commented 3 years ago

I am getting this error every time I'm trying to send messages: Microsoft.Azure.SignalR Error: 0 : [Microsoft.Azure.SignalR.AspNet.ServiceConnection]Error when processing messages. Id: 0cb6304d-88de-42d2-a8ad-3ddee974b975

The error occurs in Microsoft.Azure.SignalR.AspNet.ServiceConnection: https://github.com/Azure/azure-signalr/blob/9a850fb50772d81fb30a093465d603c094be656a/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs#L595-L596

https://github.com/Azure/azure-signalr/blob/9a850fb50772d81fb30a093465d603c094be656a/src/Microsoft.Azure.SignalR.Common/ServiceConnections/ServiceConnectionBase.cs#L486-L491

The error message is too generic, and the context of the exceptioin is lost and not trackable. Also, There is no reference as to how this error occurs or can be solved.

Startup.cs:

var applicationName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? Environment.MachineName;
var hubConfiguration = new HubConfiguration
{
    EnableDetailedErrors = true,
};
app.MapAzureSignalR(applicationName, hubConfiguration);

GlobalHost.TraceManager.Switch.Level = SourceLevels.Information;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Both the server and the client reports that they are conencted with the hub. Microsoft.Azure.SignalR Information: 0 : [Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport]Starting transport. Transfer mode: Binary. Url: 'wss://xxxxxxx.service.signalr.net/aspnetserver/?hub=xxxxx_xxxxxxxxhub&cid=f79a513e-bf52-4fb0-8fc4-09278bdffe2b&target=3d36cdd5-8aa2-4853-bbc2-3aa27fbfe792'.

image

vicancy commented 3 years ago

If it is locally repro-able, you can follow this tip to catch the exception thrown: https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-howto-troubleshoot-guide#troubleshooting-guide

andrem0 commented 3 years ago

Great, thanks for that tip. Not sure if it is an optimal way of doing debugging - I still think the underlying cause should be more available.

For me the problem was System.Threading.Channels. Microsoft.Azure.SignalR.AspNet 1.7.1 depends on System.Threading.Channels 4.6.0. I am also using StackEchange Redis (2.1.58) which depends on System.Threading.Channels 4.7.1.

An assembly redirect solved my problem:

<dependentAssembly>
    <assemblyIdentity name="System.Threading.Channels" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0"/>
</dependentAssembly>