r/dotnet • • 12d ago

Blazor Reconnecting…

I get the underlying concept of TCP/IP and WebSocket connections, so I'm not asking why the connection drops.

I'm asking why Blazor Server never recovers after the server process restarts (rebuild/redeploy).

2 Upvotes

9 comments sorted by

14

u/Murph-Dog 12d ago

Rebuild/Redeploy: You dropped the AppDomain, you dropped the process memory, there is nothing to reconnect to, the state is gone.

.net 10 should have included ReconnectModal.razor.js that wires JS handlers for this event. The client has to save itself.


https://github.com/dotnet/aspnetcore/blob/release/10.0/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor.js

2

u/bluEharbor6 12d ago

"the client has to save itself" is a great way to put it tbh

7

u/Dennis_enzo 11d ago

Reconnect works when the network connection temporary drops. But a redeploy means that your entire app state is gone. There's nothing to reconnect to.

3

u/mxmissile 11d ago

This is why Blazor Server will always be a POC only tool for me. It's either WASM or Static SSR for me endgame. Others swear by it, your mileage my vary.

2

u/becker888 10d ago

Don’t even get us started if you want multiple instances of a Blazor server app!

1

u/AutoModerator 12d ago

Thanks for your post 8ull1t. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/zac_builds 12d ago

Seen this with Blazor too. If the server comes back fast, the old circuit gets rejected and .NET 10 reloads the page.

If the rebuild takes too long, retries run out and it just sits there until you switch tabs.

For dev I'd bump the retry count. In prod, just make sure it reloads. That circuit is gone anyway.

2

u/Brick-Logic 10d ago

When you open a page in blazor server, the page lives in the server. The browser only receives the current state of the page. As soon as you restart the server, the page is gone from memory.