Blazor websocket disconnects when using Application Gateway
I have two blazor server (.NET 6) apps running as app services in Azure. The apps are to be "hidden" behind an application gateway to give users the impression that they are visiting the same site. Traffic is to be directed using parts of the url i.e {<!-- -->{domain}}/* go to app 1, {<!-- -->{domain}}/{<!-- -->{keyword}} go to app 2.
This has been set up, using routing rules on the gateway and the routing works as expected, with requests reaching the correct apps. However, when reaching app 2, the websocket immediately disconnects, killing blazor in the process. Error message displayed in the console of app 2. The apps are very barebones, containing very little code as this is a POC.
Things I have tried:
- Use Azure SignalR and not using it.
- Configured both apps to use websocket
- Use different routing rules for the two apps and use the same routing rule with two backend pools.
- Use Azure Front Door, but the same issue persists.
- Randomly toggle settings
- Added
options.ServerStickyMode = ServerStickyMode.Required;
to the signalR config in program.cs - Added `@inject Microsoft.AspNetCore.Http.IHttpContextAccessor _HttpContext
- @{ _HttpContext.HttpContext.Response.Headers["Cache-Control"] = "no-store"; }` to _Layout.cshtml with the _HttpContext. yadayada both inside the body and outside.
Maybe the most frustrating thing is that it works just fine when reaching the first app. I have tried switching the deploys, i.e. deploy app 1 code to app 2 service and vice versa, to no avail.
Have anyone else experience a similar thing? Any config or code changes I have missed?