Reputation: 186
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.
Upvotes: 6
Views: 3603
Reputation: 121
I recently had the same issue and again the accepted answer didn't help me. My project was a .NET 4.8 MVC application (so TLS version shouldn't be an issue) and following an update of the projects Nuget packages the issue arose.
I knew it was the Nuget updates that had broken my application but I didn't want to go through each one to figure out where the issue was.
Thanks to @cognophile for pointing me in the right direction. For me though I only needed to downgrade the following three Nuget packages to version 5.0.17
to fix the issue. Anything 6.x
with these packages caused the issue again.
Upvotes: 1
Reputation: 917
I've recently had the same issue whereby the negotiation worked with map.RunSignalR(...)
but not map.RunAzureSignalR(...)
and tried the accepted answer here without resolution. For anyone still experiencing this issue having tried the accepted answer like myself, I found the below to work for a .NET Framework 4.6.1
project.
Navigating to the negotiation link (e.g. .../signalr/negotiate?clientProtocol=2.1&connectionData=...&callback=jQuery...&_=...
) in the browser would give a
HTTP 500: Azure SignalR Service is not connected yet, please try again later
Having enabled the exception debugging suggestions from @Youp Hulsebos and the SignalR GitHub (source), I was able to find the following exceptions being thrown from the SignalR registration call in Startup.Configure(...)
:
Microsoft.Azure.SignalR.Common.ServiceConnectionNotActiveException: 'The connection is not active, data cannot be sent to the service.'
LoaderException - Method 'get_Features' in type 'Microsoft.AspNetCore.Http.Connections.Client.HttpConnection' from assembly 'Microsoft.AspNetCore.Http.Connections.Client, Version=1.0.0.0, Culture=neutral' does not have an implementation.":"Microsoft.AspNetCore.Http.Connections.Client.HttpConnection"
Having found the second of these exceptions and applying some Google-fu, I found this GitHub issue discussing the LoaderException
from Microsoft.Azure.SignalR.WebSocketConnectionContext
discussing this as the result of upgrading Microsoft.AspNetCore.Http.Connections.Client
from 5.0.12.0
to 6.0.0.0
.
Having tried downgrading the package to 5.0.12.0
, I still encountered the same issue. Having checked the linked issue ([dotnet/aspnetcore#38699]
), I downgraded the following packages to 5.0.11.0
and this resolved the issue:
Microsoft.AspNetCore.Connections.Abstractions
Microsoft.AspNetCore.Http.Connections.Client
Microsoft.AspNetCore.Http.Connections.Common
Microsoft.AspNetCore.Http.Features
Upvotes: 2
Reputation: 186
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.
Upvotes: 3