I don't think the websocket thing is gonna work.

This commit is contained in:
2025-07-04 23:55:51 +00:00
parent a64afa7e7b
commit 92f1366574

View File

@ -182,6 +182,7 @@ ws.on("close", (event: CloseEvent) => {
); );
ws = reconnect(ws); ws = reconnect(ws);
if (ws.readyState === WebSocket.OPEN) { if (ws.readyState === WebSocket.OPEN) {
console.log(`Reconnection to ${process.env.PLEROMA_INSTANCE_DOMAIN} successful.`)
return; return;
} }
reconnectAttempts++; reconnectAttempts++;
@ -207,13 +208,10 @@ ws.on("open", () => {
reconnectAttempts = 0; reconnectAttempts = 0;
setInterval(() => { setInterval(() => {
ws.send(JSON.stringify({ type: "ping" })); ws.send(JSON.stringify({ type: "ping" }));
console.log("Sending ping to keep session alive..."); // console.log("Sending ping to keep session alive...");
}, 20000); }, 20000);
}); });
ws.on("pong", (data) => {
console.log(`Pong received: ${JSON.stringify(data.toString("utf-8"))}`);
});
ws.on("message", async (data) => { ws.on("message", async (data) => {
try { try {
@ -229,6 +227,6 @@ ws.on("message", async (data) => {
await postReplyToStatus(payload, ollamaResponse); await postReplyToStatus(payload, ollamaResponse);
} }
} catch (error: any) { } catch (error: any) {
console.error(error.message); throw new Error(error.message);
} }
}); });