Blazor SignalR Connection Troubleshooting Print

  • 0

Overview

Blazor Server applications use SignalR for real-time communication between the browser and server. Connection issues can cause your app to become unresponsive or display "Attempting to reconnect" messages.

Common Symptoms

  • "Attempting to reconnect to the server" message appears
  • "Could not reconnect to the server" error
  • Application freezes or becomes unresponsive
  • Buttons and interactive elements stop working

Cause 1: WebSocket Connection Issues

SignalR uses WebSockets by default. If WebSockets are blocked, connections fail.

Solution: Ensure WebSockets are enabled in Plesk:

  1. This is typically enabled by default on our Windows hosting
  2. If issues persist, contact support to verify WebSocket configuration

Cause 2: HTTPS/SSL Issues

Mixed content or SSL issues can block SignalR connections.

Solution:

  • Ensure your site uses HTTPS exclusively
  • Enable "Force HTTPS" in Plesk SSL settings
  • Verify SSL certificate is valid and not expired

Cause 3: Application Pool Recycling

When the application pool recycles, all SignalR connections are dropped.

Solution: Adjust Application Pool settings in Plesk:

  1. Go to Websites & DomainsDedicated IIS Application Pool
  2. Increase Idle Timeout (default 20 minutes)
  3. Increase Private Memory Limit if your app needs more memory

Cause 4: Proxy or Load Balancer Timeout

Long-running connections may be terminated by timeouts.

Solution: Configure SignalR for longer timeouts in Program.cs:

builder.Services.AddServerSideBlazor()
    .AddHubOptions(options =>
    {
        options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
        options.HandshakeTimeout = TimeSpan.FromSeconds(30);
        options.KeepAliveInterval = TimeSpan.FromSeconds(15);
    });

Cause 5: Large Payload Issues

Very large data transfers can cause connection issues.

Solution: Increase maximum message size:

builder.Services.AddServerSideBlazor()
    .AddHubOptions(options =>
    {
        options.MaximumReceiveMessageSize = 1024 * 1024; // 1MB
    });

Debugging SignalR Issues

Enable detailed SignalR logging in appsettings.Development.json:

{
  "Logging": {
    "LogLevel": {
      "Microsoft.AspNetCore.SignalR": "Debug",
      "Microsoft.AspNetCore.Http.Connections": "Debug"
    }
  }
}

Alternative: Use WebAssembly

If SignalR issues persist, consider Blazor WebAssembly which runs entirely in the browser and does not require a persistent connection.


Was this answer helpful?

« Back