Azure SignalR Service Connection is not active

天大地大妈咪最大 提交于 2019-12-23 13:01:09

问题


I updated our signalr packages from 2.4.0 and added RunAzureSignalR instead of RunSignalR. Added this code in de Startup.cs

app.Map("/signalr", map =>
{
    var hubConfiguration = new HubConfiguration
    {
        EnableDetailedErrors = true
    };

    map.RunAzureSignalR(typeof(Startup).FullName, hubConfiguration, options =>
    {
        options.ConnectionString = AppApiSettings.SignalRServiceConnectionString;
    });
});

But when I try to send a message to the hub I get an exception The connection is not active, data cannot be sent to the service.. Can't find any reason this would happen or why the service would not run.

When I use RunSignalR (self hosted) everything runs great.

Any help would be greatly appreciated.


回答1:


It turns out Azure Service only support TLS1.2 for security concerns. Please add following code to your Startup:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

The hint for this solution was found on a github ticket: https://github.com/Azure/azure-signalr/issues/279

"No server available" indicates that your app server has trouble connecting to Azure service. You can enable tracing from the app server side with the following to see if any error throws.

GlobalHost.TraceManager.Switch.Level = SourceLevels.Information;

A sample here: https://github.com/Azure/azure-signalr/blob/dev/samples/AspNet.ChatSample/AspNet.ChatSample.SelfHostServer/Startup.cs#L19

If you are local debugging the server side, you can also uncheck "Just My Code" and break when any CLR exception throws:

System.Security.Authentication.AuthenticationException: "A call to SSPI failed, see inner exception." - (inner) "The function requested is not supported"

System.ObjectDisposedException: 'Safe handle has been closed'

System.Net.WebException: 'The request was aborted: Could not create SSL/TLS secure channel.'

System.Net.WebSockets.WebSocketException: 'Unable to connect to the remote server' - (inner) WebException: The request was aborted: Could not create SSL/TLS secure channel.



来源:https://stackoverflow.com/questions/54039861/azure-signalr-service-connection-is-not-active

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!