decrease waiting time for websocket

This commit is contained in:
MuslemRahimi 2024-11-26 21:36:00 +01:00
parent ff008f7b61
commit 5c20ba95cc

View File

@ -17,13 +17,13 @@ const path = require("path");
//const mixpanel = Mixpanel.init(mixpanelAPIKey, { debug: false }); //const mixpanel = Mixpanel.init(mixpanelAPIKey, { debug: false });
const PocketBase = require("pocketbase/cjs"); //const PocketBase = require("pocketbase/cjs");
const pb = new PocketBase("http://127.0.0.1:8090"); //const pb = new PocketBase("http://127.0.0.1:8090");
// globally disable auto cancellation // globally disable auto cancellation
//See https://github.com/pocketbase/js-sdk#auto-cancellation //See https://github.com/pocketbase/js-sdk#auto-cancellation
//Bug happens that get-post gives an error of auto-cancellation. Hence set it to false; //Bug happens that get-post gives an error of auto-cancellation. Hence set it to false;
pb.autoCancellation(false); //pb.autoCancellation(false);
const { serialize } = require("object-to-formdata"); const { serialize } = require("object-to-formdata");
@ -153,7 +153,7 @@ fastify.register(async function (fastify) {
// Start periodic data sending if not already started // Start periodic data sending if not already started
if (!sendInterval) { if (!sendInterval) {
sendInterval = setInterval(sendData, 5000); sendInterval = setInterval(sendData, 1000);
} }
}); });
@ -422,7 +422,7 @@ fastify.register(async function (fastify) {
// Start periodic data sending if not already started // Start periodic data sending if not already started
if (!sendInterval) { if (!sendInterval) {
sendInterval = setInterval(sendData, 5000); sendInterval = setInterval(sendData, 1000);
} }
} catch (err) { } catch (err) {
console.error("Failed to parse tickers from client message:", err); console.error("Failed to parse tickers from client message:", err);
@ -463,8 +463,6 @@ fastify.register(async function (fastify) {
); );
}); });
// Function to start the server // Function to start the server
function startServer() { function startServer() {
if (!serverRunning) { if (!serverRunning) {