6

When deploying our blazor app to azure, it fails four out of five times with this error (copied from chrome dev tools):

[2019-12-16T11:12:55.214Z] Information: Normalizing '_blazor' to 'https://example.com/_blazor'.
[2019-12-16T11:12:55.470Z] Information: WebSocket connected to wss://example-web-signalr-service.service.signalr.net/client/?hub=componenthub&asrs.op=%2F_blazor&negotiateVersion=1&asrs_request_id=...&id=...&access_token=...
[2019-12-16T11:12:55.548Z] Error: The list of component records is not valid.
    e.log @ blazor.server.js:15
    C @ blazor.server.js:8
    (anonymous) @ blazor.server.js:8
    (anonymous) @ blazor.server.js:1
    e.invokeClientMethod @ blazor.server.js:1
    e.processIncomingData @ blazor.server.js:1
    connection.onreceive @ blazor.server.js:1
    i.onmessage @ blazor.server.js:1
[2019-12-16T11:12:55.552Z] Information: Connection disconnected.
Uncaught (in promise) Error: Invocation canceled due to the underlying connection being closed.
    at e.connectionClosed (blazor.server.js:1)
    at e.connection.onclose (blazor.server.js:1)
    at e.stopConnection (blazor.server.js:1)
    at e.transport.onclose (blazor.server.js:1)
    at e.close (blazor.server.js:1)
    at e.stop (blazor.server.js:1)
    at e.<anonymous> (blazor.server.js:1)
    at blazor.server.js:1
    at Object.next (blazor.server.js:1)
    at a (blazor.server.js:1)

We can't make any sense out of this. What might be the cause for blazor to fail like this? Why doesn't it fail on our local developer machines? It is hard to find anything about this in google.

Please tell me if I need to provide more information. I am not sure which code snippets might be useful information.

2
  • I would remove the SignalR service and just turn on web sockets in Azure. I have had no problems at all doing it this way. Commented Dec 16, 2019 at 13:08
  • I have turned on Web Sockets and ARR and I still get the same error message? Works fine locally on my dev machine, as soon as I deploy to Azure I get this error
    – YodasMyDad
    Commented Dec 21, 2021 at 11:11

1 Answer 1

14

try this:

services.AddSignalR().AddAzureSignalR(options =>
{
    options.ServerStickyMode = Microsoft.Azure.SignalR.ServerStickyMode.Required;
});
3
  • Perfect. "The typical connection flow when using SignalR service is that client first negotiates with app server to get the url of SignalR service, then service routes client to app server. When you have multiple app servers, there is no guarantee that two servers (the one who does negotiation and the one who gets the hub invocation) will be the same one." That setting is to make the two servers the same one so they can share some states between negotiation and hub invocation. Read more: github.com/Azure/azure-signalr/blob/dev/docs/…
    – Kamran
    Commented Dec 16, 2019 at 13:12
  • 1
    Thank you, I ended up using a very similar solution in my app. In my app I wrapped this code in if (!HostingEnvironment.IsDevelopment()) { ... } because I only use the Azure SignalR service in production/staging and not in development mode.
    – Eilon
    Commented Jun 2, 2020 at 5:52
  • I am using IIS, is this option also available? Commented Oct 9, 2023 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.