Open Closed

Microservice with Blazor Server UI inside kubernetes not working when spec.replicas > 1 #2063


User avatar
0
truong.nguyen@outlook.com created

Hi, I'm having issue running the microservice template with blazor server ui running inside kubernetes. I was able to have all services and auth-server running fine inside kubernetes. Blazor Server UI runs fine if spec.replicas = 1; however, if I have Blazor Server spec.replicas > 1, I'd get a websocket connection failed from the browser. I've tried the following but none successful:

Environments:

  • Google GKE Kubernetes
  • Nginx Ingress Controller
  • Microservice Template v4.4.3

BlazorModule.cs

public override void PreConfigureServices(ServiceConfigurationContext context)
{
    ...

    context.Services.PreConfigure<ISignalRServerBuilder>(builder =>
    {
        builder.AddStackExchangeRedis(configuration["Redis:Configuration"], options =>
        {
            options.Configuration.ChannelPrefix = "Blazor-Channel";
        });
    });
}
        
public override void ConfigureServices(ServiceConfigurationContext context)
{
    ...
    
    context.Services.Configure<ForwardedHeadersOptions>(options =>
    {
        options.ForwardedHeaders =
            ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
    });
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
    ...
    
    app.UseCookiePolicy(); // added this, Before UseAuthentication or anything else that writes cookies.
    app.UseForwardedHeaders();
}

Ingress.yml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: blazor-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "affinity"
    nginx.ingress.kubernetes.io/session-cookie-expires: "14400"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "14400"
    nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.4.3
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

2 Answer(s)
  • User Avatar
    0
    truong.nguyen@outlook.com created

    Any progress on this issue?

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Hello, We don't have experience on kubernetes deployment of Blazor.Server application yet.

    Can you successfully deploy with replicas a new microsoft default blazor.server application so that we can verify it is about abp template?

    Furthermore, Is there any console logs on server when try to increase replicas?

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on May 15, 2025, 10:28