[Blazor Server] Blazor Server Freezes When Opening A New Tab
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
When hosting the Blazor Server App on my own IIS with Windows 10 almost every time I open another instance of my application it freezes essentially as indicated in the screenshot above. Any clues what may be causing this? I am using a SignalR Hub that I created which is very simple.
The above situation also occurs any time I press the refresh button on the browser.
Expected Behavior
It should not be stuck loading, but rather open a new instance of the app.
In the event of a refresh, it should simply refresh the page.
Steps To Reproduce
Simply go to the site linked and open a new instance of the home tab on the left side.
Exceptions (if any)
I see no exceptions or errors logged in the console.
.NET Version
dotnet --version 6.0.401
Anything else?
https://charactermanager.ddns.net/CharacterManager
There is a link to the site in question so you can do any troubleshooting necessary.
I discovered the issue, this was a SignalR issue. I decided to implement a new mechanism to updating the sheets than simply using a page refresh.
this was a SignalR issue
Care to elaborate?
Sure, basically SignalR doesn't like page refreshes. Basically it does something with the websocket connection and the appPool basically just spins endlessly. It is not recommended to use a page refresh when using SignalR, at least from what I read. I simply do an InvokeAsync(StateHasChanged) and update the data. Blazor updates everything as expected.
SignalR doesn't like page refreshes
The connection will be closed, so a new connection will need to be created on refresh. This means you lose state associated with that connection and have to do extra work to get back the old state if that's what you want your app to do (blazor has some built-in logic for this).
I simply do an InvokeAsync(StateHasChanged) and update the data. Blazor updates everything as expected.
That is much better than refreshing 😃
the appPool basically just spins endlessly
This doesn't sound good, is it possible to share a github project that repros this?
The connection will be closed, so a new connection will need to be created on refresh. This means you lose state associated with that connection and have to do extra work to get back the old state if that's what you want your app to do (blazor has some built-in logic for this).
Interesting, what kind of logic does blazor have to do that? Is that something I would need to invoke/call?
This doesn't sound good, is it possible to share a github project that repros this?
I can see if I can push up a copy of what I have, I will add a link shortly. It seems now my app just doesn't like me navigating anywhere once I am connected via SignalR.
Here is a link to my github: https://github.com/taldorblackfire/CharacterManager/tree/master/CharacterManager
Edit.Razor and Manage.Razor are the only two pages with the ability to connect to the hub I created, just to help filter through my madness. @BrennanConroy should have access now
How do you run the project? The database doesn't seem to be setup properly?
InvalidOperationException: Role USER does not exist. Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>.AddToRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken)
I run it using Visual Studio 2022. I removed some of the connection string objects and database location. I can add those if needed though.
It should be updated now.
I don't want to connect to your database, could you just update the migrations needed for creating the db locally? https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/migrations?view=aspnetcore-6.0&tabs=visual-studio
So... the data is very complex, I can get to work on it though.
Well if it's easy to remove some of the complexity and still repro the issue that would be ideal.
That is the tricky part, but I can work on a simplified version. May take some time and I can post that up. I have a basic test project that utilizes a chat hub from MIcrosoft. I see the same issue when trying to have multiple connections when hosted on IIS. Works like a dream when debugging, dies on IIS. Want me to link that repo?
Sure
Alright, so this project is a similar deal. It uses an Application named "Test" that is appended on to the Default Web Site provided by IIS. Here is the link: https://github.com/taldorblackfire/Test
When I open "Home" in a new tab, the "Send" button is disabled. Which seems to be based on a connection to the hub being made.
This does not repro for me in IIS. I'm guessing there is something odd with your IIS configuration or machine.
Interesting, what are your configurations within IIS?
I am using the App Pool of v4.0 .NET CLR and Integrated Pipeline.
It was an issue of my machine, thanks for the help!