问题描述
我从2.4.0更新了Signalr软件包,并添加了RunAzureSignalR
而不是RunSignalR
.在Startup.cs
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;
});
});
但是,当我尝试向集线器发送消息时,出现异常The connection is not active, data cannot be sent to the service.
.找不到发生这种情况的任何原因或该服务无法运行的原因.
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.
当我使用RunSignalR(自行托管)时,一切运行良好.
When I use RunSignalR (self hosted) everything runs great.
任何帮助将不胜感激.
推荐答案
事实证明,Azure服务出于安全性考虑仅支持TLS1.2.请在您的启动中添加以下代码:
It turns out Azure Service only support TLS1.2 for security concerns.Please add following code to your Startup:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
此解决方案的提示在github票证上找到: https://github .com/Azure/azure-signalr/issues/279
无可用服务器"表示您的应用服务器无法连接到Azure服务.您可以使用以下命令从应用服务器端启用跟踪,以查看是否抛出任何错误.
"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;
如果您是在本地调试服务器端,还可以取消选中"Just My Code"(Just我的代码)并在任何CLR异常抛出时中断:
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:对SSPI的调用失败,请参阅内部异常.-(内部)不支持所请求的功能"
System.Security.Authentication.AuthenticationException: "A call to SSPI failed, see inner exception."- (inner) "The function requested is not supported"
System.ObjectDisposedException:'安全句柄已关闭'
System.ObjectDisposedException: 'Safe handle has been closed'
System.Net.WebException:请求已中止:无法创建SSL/TLS安全通道."
System.Net.WebException: 'The request was aborted: Could not create SSL/TLS secure channel.'
System.Net.WebSockets.WebSocketException:'无法连接到远程服务器'-(内部)WebException:请求已中止:无法创建SSL/TLS安全通道.
System.Net.WebSockets.WebSocketException: 'Unable to connect to the remote server'- (inner) WebException: The request was aborted: Could not create SSL/TLS secure channel.
这篇关于Azure SignalR服务连接未激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!