Blazor websocket disconnects when using Application Gateway

Jon Eirik Lisle Andresen 1 Reputation point

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:

  1. Use Azure SignalR and not using it.
  2. Configured both apps to use websocket
  3. Use different routing rules for the two apps and use the same routing rule with two backend pools.
  4. Use Azure Front Door, but the same issue persists.
  5. Randomly toggle settings
  6. Added options.ServerStickyMode = ServerStickyMode.Required; to the signalR config in program.cs
  7. Added `@inject Microsoft.AspNetCore.Http.IHttpContextAccessor _HttpContext
  8. @{ _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?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
842 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,204 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,033 questions
{count} votes