SignalR 与 Azure 的连接不起作用(.net core 3.1)

Fre*_*ens 3 azure signalr .net-core

我正在尝试将我的应用程序与Azure SignalR 连接,但似乎没有建立连接。

当我在基本配置文件中使用并在本地运行程序时,一切正常:

services.AddSignalR();
Run Code Online (Sandbox Code Playgroud)

但是当我像这样将其更改为Azure时(我在这里硬编码了密钥)

services.AddSignalR().AddAzureSignalR("Endpoint=https://frenscoservice.service.signalr.net;AccessKey=<MYKEY>;Version=1.0;");
Run Code Online (Sandbox Code Playgroud)

我在客户端收到错误消息

“无法加载资源:服务器响应状态为 500(内部服务器错误)”

“错误:无法完成与服务器的协商:错误:内部服务器错误”

我设法获得了下面的完整服务器日志文件。任何指针将不胜感激。我仍然可以选择默认运行 SignalR,而不使用 Azure,但我对 SignalR 进行了数千次调用,Azure 似乎解释说使用他们的服务会更快。

Starting IIS Express ...
Successfully registered URL "http://localhost:61663/" for site "Traveller" application "/"
Successfully registered URL "https://localhost:44380/" for site "Traveller" application "/"
Registration completed for site "Traveller"
IIS Express is running.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubProtocolResolver[1]
      Registered SignalR Protocol: json, implemented by Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3ecd8966-8daa-4086-9814-c31f11ba7e66.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3ecd8966-8daa-4086-9814-c31f11ba7e66'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3809c62f-7960-4596-af76-f96589bc9e27.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3809c62f-7960-4596-af76-f96589bc9e27'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3bfd6373-814e-4f54-a86f-0f187e34ea55.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=3bfd6373-814e-4f54-a86f-0f187e34ea55'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=f128631e-ff15-4882-82a8-9aeaf47db2ee.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=f128631e-ff15-4882-82a8-9aeaf47db2ee'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=ebab1e46-a273-4e83-8649-39aad83c18ce.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=ebab1e46-a273-4e83-8649-39aad83c18ce'.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\francois.debodinat\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Development
Content root path: C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller
Now listening on: http://localhost:61663/
Now listening on: https://localhost:44380/
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/  
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Traveller.Controllers.DefinitionController.Index (Traveller)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
      Route matched with {action = "Index", controller = "Definition"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Index() on controller Traveller.Controllers.DefinitionController (Traveller).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: 3bfd6373-814e-4f54-a86f-0f187e34ea55
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: f128631e-ff15-4882-82a8-9aeaf47db2ee
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: 3809c62f-7960-4596-af76-f96589bc9e27
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: 3ecd8966-8daa-4086-9814-c31f11ba7e66
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: ebab1e46-a273-4e83-8649-39aad83c18ce
fail: Microsoft.Azure.SignalR.StrongServiceConnectionContainer[2]
      Hub 'NotificationsHub' is now disconnected from '(Primary)https://frenscoservice.service.signalr.net'. Please check log for detailed info.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
      Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
      Starting transport 'WebSockets' with Url: https://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=b81c6688-9239-4342-897f-86c3bd7f7c6d.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://frenscoservice.service.signalr.net/server/?hub=notificationshub&cid=b81c6688-9239-4342-897f-86c3bd7f7c6d'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
      Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
      Transport 'WebSockets' started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
      HttpConnection Started.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
      Received message from application. Payload size: 4.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
      Message received. Type: Binary, size: 48, EndOfMessage: True.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11]
      WebSocket closed by the server. Close status NormalClosure.
crit: Microsoft.Azure.SignalR.ServiceConnection[24]
      Service returned handshake error: Maximum message count limit reached: 20000. Id: b81c6688-9239-4342-897f-86c3bd7f7c6d
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[4]
      Receive loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4]
      Disposing HttpConnection.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[6]
      Transport is stopping.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[8]
      Send loop stopped.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[2]
      Transport stopped.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[6]
      HttpConnection Disposed.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[1]
      Executing ViewResult, running view Index.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[4]
      Executed ViewResult - view Index executed in 235.3981ms.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/css/bootstrap.css  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/jquery-3.3.1.js?2300  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/jquery-3.3.1.min.js?2500  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/JSKonvaSearch.js?2000  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/bootstrap.bundle.js?2400  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/signalr/signalr.js?2800  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/JSUtils.js?2000  
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
      Executed action Traveller.Controllers.DefinitionController.Index (Traveller) in 1169.127ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Traveller.Controllers.DefinitionController.Index (Traveller)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/JSGlobals.js?2000  
info: Microsoft.AspNetCore.Session.DistributedSession[3]
      Session started; Key:7337807d-0554-d5b7-e2b1-bb23dae40b59, Id:d2077465-8aea-9f6f-2e81-7d3074ea87e2
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/js/JSKonvaSearch.js'. Physical path: 'C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller\wwwroot\js\JSKonvaSearch.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/js/JSGlobals.js'. Physical path: 'C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller\wwwroot\js\JSGlobals.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/js/JSUtils.js'. Physical path: 'C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller\wwwroot\js\JSUtils.js'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 19.3002ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 59.6407ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 58.1304ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/bootstrap.bundle.min.js?2600  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/JSKonvaDraw.js?2000  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/konva.2.4.2.min.js?2200  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/lib/js/Chart.bundle.v2.7.3.min.js?2800  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/JSDashboard.js?2000  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/css/site.css  
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2.0 GET https://localhost:44380/js/signalr/signalr.min.js?2850  
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 1308.065ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/js/JSKonvaDraw.js'. Physical path: 'C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller\wwwroot\js\JSKonvaDraw.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/lib/js/jquery-3.3.1.min.js'. Physical path: 'C:\Users\francois.debodinat\Documents\_perso code\ProjectTraveller\Traveller\wwwroot\lib\js\jquery-3.3.1.min.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/lib/js/bootstrap.bundle.min.js'. Physical path: 'C:\Users\francois.debodinat\Doc

Kir*_*512 5

这发生在我的冲刺审核当天,当时我们达到了免费套餐 Azure SignalR 服务的最大消息计数。正如您在日志中看到的,您重新设置了 20k 消息限制。

crit:Microsoft.Azure.SignalR.ServiceConnection[24] 服务返回握手错误:达到最大消息计数限制:20000。ID:535de32b-cedb-4cda-9959-675e6712f6ac

信息:Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[11] WebSocket 由服务器关闭。关闭状态NormalClosure。

dbug:Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[4] 处置 HttpConnection。

您只需创建一项新的免费 Azure SignalR 服务并更改新服务或升级的密钥即可。在我们的开发过程中,我们只是在它几乎完成之前创建了新的,并将其更改为标准层。

SignalR 定价等级