mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 18:49:06 +00:00
Fixes #45
This commit is contained in:
parent
af37a5b0e5
commit
e4f045a2cc
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
<body style="overflow: hidden;">
|
<body style="overflow: hidden;">
|
||||||
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)"/>
|
<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/MudBlazor.min.js"></script>
|
||||||
<script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
|
<script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
|
@ -30,9 +30,11 @@ builder.Services.AddSingleton<SettingsManager>();
|
|||||||
builder.Services.AddSingleton<Random>();
|
builder.Services.AddSingleton<Random>();
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents()
|
.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";
|
var port = args.Length > 0 ? args[0] : "5000";
|
||||||
|
66
app/MindWork AI Studio/wwwroot/boot.js
Normal file
66
app/MindWork AI Studio/wwwroot/boot.js
Normal 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);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user