Skip to content

SignalR KeepAlive Interval not being honored - Blazor Server #48675

Closed
@garrettlondon1

Description

@garrettlondon1

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-7.0#configure-signalr-timeouts-and-keep-alive-on-the-client

Documentation says:

The server timeout should be at least double the value assigned to the Keep-Alive interval.
The Keep-Alive interval should be less than or equal to half the value assigned to the server timeout

When specifying the Keep-Alive interval as 5000ms and Server Timeout as 30000ms, the Keep-Alive still defaults to 15 seconds

Expected Behavior

Keep-Alive interval is honored. Currently if a user disconnects from SignalR or has a connection issue, when a button is pressed in Server-side blazor application the UI hangs for 15 seconds before displaying the reconnection modal.

One solution using the Keep-Alive should be to send more frequent pings so that it is quicker to tell when a client is not receiving DOM updates.

Steps To Reproduce

<script src="_framework/blazor.{HOSTING MODEL}.js" autostart="false"></script>
<script>
  Blazor.start({
    configureSignalR: function (builder) {
      let c = builder.build();
      c.serverTimeoutInMilliseconds = 30000;
      c.keepAliveIntervalInMilliseconds = 5000;
      builder.build = () => {
        return c;
      };
    }
  });
</script>

Using the script above if you inspect the WS connection in JS console, you will see pings of 15 seconds, regardless of Keep-Alive

Exceptions (if any)

No response

.NET Version

7.0.32

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions