Better reconnection logic for Blazor Server · Issue #32113 · dotnet/aspnetcore (original) (raw)

Summary

Currently there is an issue with Blazor Server-side where it is not reconnecting circuits automatically and losing connection especially on mobile browsers.

See #23340 #26985

Motivation and goals

In scope

image

Out of scope

Risks / unknowns

Examples

DefaultReconnectionHandler.ts

async attemptPeriodicReconnection(options: ReconnectionOptions) { for (let i = 0; i < options.maxRetries; i++) { this.reconnectDisplay.update(i + 1);

  const delayDuration = i == 0 && options.retryIntervalMilliseconds > ReconnectionProcess.MaximumFirstRetryInterval
                        ? ReconnectionProcess.MaximumFirstRetryInterval
                        : options.retryIntervalMilliseconds;
  this.logger.log(LogLevel.Debug, `Reconnecting in ${delayDuration}`);
  await this.delay(delayDuration);
  //code..
  //try { reconnect() }
  
 //instead of delaying 3000ms first and trying to reconnect later
 //we could try to reconnect first and delay afterwards
 //this could possibly fix reconnection on suspended mobile browsers

Example onReconnectionFailed event default implementation

Blazor.defaultReconnectionHandler.onReconnectionFailed = function (d) {
    document.location.reload(); 
}

I can take care of the implementation of this task.

#23340
#26985
#40721
#30344
#41791