Scale out Blazor Server App using Azure cache Redis as backplane

Kevin Seng 0 Reputation points
2024-09-18T10:05:25.38+00:00

I am current hosting Blazor server app in Azure App Service. I found an issue when my application scale out. So i change to use Azure cache Redis for SignalR backplane. I also enable session affinity with my App Service configuration. Most of the time I see it work. but sometimes I get the error "No Connection with that ID". My question if I already use Redis as SignalR backplane. Why the connection get lost?

https://domain.com/_blazor?id=LyHnNyvFmFyWwaeNQjx5cQ&_=1726649919956

No Connection with that ID: Status code '404'

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,559 questions
Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
250 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,679 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 64,486 Reputation points
    2024-09-18T15:52:12.67+00:00

    If the Blazor server app is hosted in Azure, Azure Signal/r is recommended over using Redis cache. Anyway blazor server requires a constant websocket connection. If lost the server has a couple minute timeout (~4 minutes, configurable) on the circuit, after which the circuit context is closed, and the client must reload.

    Browsers are getting more aggressive in shutting down websockets (especially mobile, but desktop is following the trend). If the tab is not the active tab, the websocket may be closed. The same may happen if the browser is not the active application.

    you can counteract the browser behavior, by setting a higher circuit timeout. This will of course use more server resources, as a tab close or navigation away would leave the circuit open longer on the server.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.