Fix for timeout error

This commit is contained in:
Selim Mustafaev 2025-06-03 10:39:57 +03:00
parent 1e3066cea7
commit bf34e53d5b

View File

@ -22,6 +22,10 @@ const sign = {
let deviceToken = uuidv4().replaceAll('-', '').toUpperCase(); let deviceToken = uuidv4().replaceAll('-', '').toUpperCase();
var cookie = null; var cookie = null;
setInterval(() => {
cookie = null;
}, 10*60*60*1000);
const myWs = function (options) { const myWs = function (options) {
return class wsClass extends WebSocket { return class wsClass extends WebSocket {
constructor(...args) { constructor(...args) {
@ -140,7 +144,10 @@ function getToken(ctx) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch(tokenRefreshUrl, { fetch(tokenRefreshUrl, {
method: 'POST', method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }), headers: new Headers({
'Content-Type': 'application/json',
'cookie': cookie
}),
body: JSON.stringify(ctx) body: JSON.stringify(ctx)
}) })
.then(res => { .then(res => {
@ -184,7 +191,7 @@ function waitForReport(centrifugoConfig, channel) {
} else { } else {
reject(new Error('Request to avtocod timed out')); reject(new Error('Request to avtocod timed out'));
} }
}, 10000); }, 15000);
const sub = centrifuge.newSubscription(channel); const sub = centrifuge.newSubscription(channel);