加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – Azure SignalR服务连接未激活

发布时间:2020-12-16 09:44:04 所属栏目:asp.Net 来源:网络整理
导读:我更新了2.4.0的信号器包,并添加了RunAzureSignalR而不是RunSignalR.在de Startup.cs中添加了此代码 app.Map("/signalr",map ={ var hubConfiguration = new HubConfiguration { EnableDetailedErrors = true }; map.RunAzureSignalR(typeof(Startup).FullNa
我更新了2.4.0的信号器包,并添加了RunAzureSignalR而不是RunSignalR.在de Startup.cs中添加了此代码

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

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

但是,当我尝试向集线器发送消息时,我得到一个异常连接未激活,数据无法发送到服务..无法找到任何原因会发生这种情况或服务无法运行的原因.

当我使用RunSignalR(自托管)时,一切都运行良好.

任何帮助将不胜感激.

解决方法

事实证明,Azure Service仅支持TLS1.2以解决安全问题.
请在启动时添加以下代码:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

这个解决方案的提示是在github票证上找到的:https://github.com/Azure/azure-signalr/issues/279

“无可用服务器”表示您的应用服务器无法连接到Azure服务.您可以使用以下内容从应用服务器端启用跟踪,以查看是否有任何错误抛出.

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

这里有一个样本:https://github.com/Azure/azure-signalr/blob/dev/samples/AspNet.ChatSample/AspNet.ChatSample.SelfHostServer/Startup.cs#L19

如果您在本地调试服务器端,您也可以取消选中“Just My Code”并在任何CLR异常抛出时中断:

Disable just my code


enter image description here


System.Security.Authentication.AuthenticationException:“对SSPI的调用失败,请参阅内部异常.”
– (内部)“不支持请求的功能”

System.ObjectDisposedException:’安全句柄已关闭’

System.Net.WebException:’请求已中止:无法创建SSL / TLS安全通道.

System.Net.WebSockets.WebSocketException:’无法连接到远程服务器’ – (内部)WebException:请求已中止:无法创建SSL / TLS安全通道.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读