@tthr/vue 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,7 +21,7 @@ let heartbeatTimeoutTimer = null;
|
|
|
21
21
|
let awaitingPong = false;
|
|
22
22
|
let shouldReconnect = true;
|
|
23
23
|
const MAX_RECONNECT_ATTEMPTS = 10;
|
|
24
|
-
const HEARTBEAT_INTERVAL =
|
|
24
|
+
const HEARTBEAT_INTERVAL = 20000; // 20 seconds - keeps connection alive through proxies with 30s idle timeout
|
|
25
25
|
const HEARTBEAT_TIMEOUT = 10000;
|
|
26
26
|
const RECONNECT_DELAY = 1000;
|
|
27
27
|
/**
|
|
@@ -143,6 +143,7 @@ function startHeartbeat() {
|
|
|
143
143
|
heartbeatTimer = setInterval(() => {
|
|
144
144
|
if (ws?.readyState === WebSocket.OPEN) {
|
|
145
145
|
awaitingPong = true;
|
|
146
|
+
console.log('[Tether Cron] Sending heartbeat ping');
|
|
146
147
|
ws.send(JSON.stringify({ type: 'ping' }));
|
|
147
148
|
heartbeatTimeoutTimer = setTimeout(() => {
|
|
148
149
|
if (awaitingPong) {
|
|
@@ -151,6 +152,9 @@ function startHeartbeat() {
|
|
|
151
152
|
}
|
|
152
153
|
}, HEARTBEAT_TIMEOUT);
|
|
153
154
|
}
|
|
155
|
+
else {
|
|
156
|
+
console.warn(`[Tether Cron] Cannot send ping - WebSocket state: ${ws?.readyState}`);
|
|
157
|
+
}
|
|
154
158
|
}, HEARTBEAT_INTERVAL);
|
|
155
159
|
}
|
|
156
160
|
function stopHeartbeat() {
|
|
@@ -192,6 +196,7 @@ function connect(config) {
|
|
|
192
196
|
await handleCronTrigger(config, message);
|
|
193
197
|
break;
|
|
194
198
|
case 'pong':
|
|
199
|
+
console.log('[Tether Cron] Received pong');
|
|
195
200
|
awaitingPong = false;
|
|
196
201
|
if (heartbeatTimeoutTimer) {
|
|
197
202
|
clearTimeout(heartbeatTimeoutTimer);
|
|
@@ -211,10 +216,10 @@ function connect(config) {
|
|
|
211
216
|
const err = error instanceof Error ? error : new Error('WebSocket error');
|
|
212
217
|
console.error('[Tether Cron] WebSocket error:', err.message);
|
|
213
218
|
};
|
|
214
|
-
ws.onclose = () => {
|
|
219
|
+
ws.onclose = (event) => {
|
|
215
220
|
connectionId = null;
|
|
216
221
|
stopHeartbeat();
|
|
217
|
-
console.log(
|
|
222
|
+
console.log(`[Tether Cron] WebSocket disconnected (code: ${event.code}, reason: ${event.reason || 'none'})`);
|
|
218
223
|
handleReconnect(config);
|
|
219
224
|
};
|
|
220
225
|
}
|