事实证明,出于安全考虑,Azure 服务仅支持 TLS1.2。
请将以下代码添加到您的启动中:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
这个解决方案的提示是在 github 票证上找到的:https://github.com/Azure/azure-signalr/issues/279 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 https://github.com/Azure/azure-signalr/blob/dev/samples/AspNet.ChatSample/AspNet.ChatSample.SelfHostServer/Startup.cs#L19
如果您在本地调试服务器端,您还可以取消选中“Just My Code”,并在任何 CLR 异常抛出时中断:
System.Security.Authentication.AuthenticationException: "A call to SSPI failed, see inner exception."
- (inner) "The function requested is not supported"
System.ObjectDisposeException:“安全句柄已关闭”
System.Net.WebException:“请求已中止:无法创建 SSL/TLS 安全通道。”
System.Net.WebSockets.WebSocketException:“无法连接到远程服务器”
-(内部)WebException:请求已中止:无法创建 SSL/TLS 安全通道。