Aspnetcore: [Blazor] Change client-side default reconnection options

Created on 3 Feb 2020  路  2Comments  路  Source: dotnet/aspnetcore

The server keeps disconnected circuits around for 3 minutes by default.

https://github.com/dotnet/aspnetcore/blob/6255c1ed960f5277d2e96ac2d0968c2c7e844ce2/src/Components/Server/src/CircuitOptions.cs#L47

However, the client gives up trying to reconnect after just 15 seconds.

const defaultOptions: BlazorOptions = {
configureSignalR: (_) => { },
logLevel: LogLevel.Warning,
reconnectionOptions: {
maxRetries: 5,
retryIntervalMilliseconds: 3000,
dialogId: 'components-reconnect-modal',
},

This causes issues with apps running on mobile browsers as the app looses the connection when the browser is sent to the background. We should change these defaults values to something more sensible that matches the defaults on the server.

For example, we should change to one of the following options:

  • Retry 6 times every 30 seconds.
  • Retry 12 times every 15 seconds.
  • Retry 36 times every 5 seconds.

Any of these options ensures that the client doesn't give up before the server does.
We should consider patching this as its cheap and the current experience is bad

Additionally, we should consider including some sort of progress indicator (like the attempt number) in the UI we render while we are trying to reconnect. The current UI does not provide any progress and that leads to a bad UX experience, making users prone to close the browser or refresh the page.

Done area-blazor bug good first issue help wanted

Most helpful comment

We should also consider using https://developer.mozilla.org/en-US/docs/Web/API/Document/onvisibilitychange (or similar API) to attempt reconnection immediately when the tab regains focus, regardless of the update cycle.

All 2 comments

We should also consider using https://developer.mozilla.org/en-US/docs/Web/API/Document/onvisibilitychange (or similar API) to attempt reconnection immediately when the tab regains focus, regardless of the update cycle.

Question: is it possible for SignalR to reconnect if server was restarted? It seems in production restart of server will result in unsuccessfull tries for reconnection, though there are messages in console like "connected to websocket", but any actions on page result in "cannot something something when not in status Connected" and circuit errors or something.

I mean maybe this can be configured or something?

Was this page helpful?
0 / 5 - 0 ratings