This commit is contained in:
Thorsten Sommer 2024-05-31 22:09:43 +02:00
parent af37a5b0e5
commit e4f045a2cc
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 72 additions and 3 deletions

View File

@ -17,7 +17,8 @@
<body style="overflow: hidden;">
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)"/>
<script src="_framework/blazor.web.js"></script>
<script src="_framework/blazor.web.js" autostart="false"></script>
<script src="boot.js"></script>
<script src="system/MudBlazor/MudBlazor.min.js"></script>
<script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
<script src="app.js"></script>

View File

@ -30,9 +30,11 @@ builder.Services.AddSingleton<SettingsManager>();
builder.Services.AddSingleton<Random>();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddHubOptions(x =>
.AddHubOptions(options =>
{
x.MaximumReceiveMessageSize = null;
options.MaximumReceiveMessageSize = null;
options.ClientTimeoutInterval = TimeSpan.FromSeconds(1_200);
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
});
var port = args.Length > 0 ? args[0] : "5000";

View File

@ -0,0 +1,66 @@
(() => {
const maximumRetryCount = 3;
const retryIntervalMilliseconds = 500;
const reconnectModal = document.getElementById('reconnect-modal');
const startReconnectionProcess = () => {
reconnectModal.style.display = 'block';
let isCanceled = false;
(async () => {
for (let i = 0; i < maximumRetryCount; i++) {
reconnectModal.innerText = `Attempting to reconnect: ${i + 1} of ${maximumRetryCount}`;
await new Promise(resolve => setTimeout(resolve, retryIntervalMilliseconds));
if (isCanceled) {
return;
}
try {
const result = await Blazor.reconnect();
if (!result) {
// The server was reached, but the connection was rejected; reload the page.
location.reload();
return;
}
// Successfully reconnected to the server.
return;
} catch {
// Didn't reach the server; try again.
}
}
// Retried too many times; reload the page.
location.reload();
})();
return {
cancel: () => {
isCanceled = true;
reconnectModal.style.display = 'none';
},
};
};
let currentReconnectionProcess = null;
Blazor.start({
circuit: {
reconnectionHandler: {
onConnectionDown: () => currentReconnectionProcess ??= startReconnectionProcess(),
onConnectionUp: () => {
currentReconnectionProcess?.cancel();
currentReconnectionProcess = null;
}
},
configureSignalR: function (builder) {
builder.withServerTimeout(1_200_000);
builder.withKeepAliveInterval(30_000);
},
}
});
})();