Unverified Commit 70a8f6e7 authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge pull request #4431 from Nowheresly/fix4158_reconnect

feat: #4158 allow reconnection when websocket is closed
parents ad9a7cb1 2fb4d335
......@@ -69,6 +69,7 @@ type ChatCompletedForm = {
model: string;
messages: string[];
chat_id: string;
session_id: string;
};
export const chatCompleted = async (token: string, body: ChatCompletedForm) => {
......
......@@ -111,6 +111,10 @@
if ($config) {
const _socket = io(`${WEBUI_BASE_URL}` || undefined, {
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
randomizationFactor: 0.5
path: '/ws/socket.io',
auth: { token: localStorage.token }
});
......@@ -119,6 +123,21 @@
console.log('connected');
});
_socket.on("reconnect_attempt", (attempt) => {
console.log('reconnect_attempt', attempt);
});
_socket.on("reconnect_failed", () => {
console.log('reconnect_failed');
});
_socket.on("disconnect", (reason, details) => {
console.log(`Socket ${socket.id} disconnected due to ${reason}`);
if (details) {
console.log('Additional details:', details);
}
});
await socket.set(_socket);
_socket.on('user-count', (data) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment