fix acceleration websocket timeout loop
This commit is contained in:
parent
073fe8e8cd
commit
abe9aa1fdc
@ -247,6 +247,7 @@ class AccelerationApi {
|
|||||||
if (!this.ws) {
|
if (!this.ws) {
|
||||||
this.ws = new WebSocket(this.websocketPath);
|
this.ws = new WebSocket(this.websocketPath);
|
||||||
this.websocketConnected = true;
|
this.websocketConnected = true;
|
||||||
|
this.lastPing = 0;
|
||||||
|
|
||||||
this.ws.on('open', () => {
|
this.ws.on('open', () => {
|
||||||
logger.info(`Acceleration websocket opened to ${this.websocketPath}`);
|
logger.info(`Acceleration websocket opened to ${this.websocketPath}`);
|
||||||
@ -286,12 +287,13 @@ class AccelerationApi {
|
|||||||
this.lastPong = Date.now();
|
this.lastPong = Date.now();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (this.lastPing > this.lastPong && Date.now() - this.lastPing > 10000) {
|
if (this.lastPing && this.lastPing > this.lastPong && (Date.now() - this.lastPing > 10000)) {
|
||||||
logger.warn('No pong received within 10 seconds, terminating connection');
|
logger.warn('No pong received within 10 seconds, terminating connection');
|
||||||
this.ws.terminate();
|
this.ws.terminate();
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
this.websocketConnected = false;
|
this.websocketConnected = false;
|
||||||
} else if (Date.now() - this.lastPing > 30000) {
|
this.lastPing = 0;
|
||||||
|
} else if (!this.lastPing || (Date.now() - this.lastPing > 30000)) {
|
||||||
logger.debug('sending ping to acceleration websocket server');
|
logger.debug('sending ping to acceleration websocket server');
|
||||||
this.ws.ping();
|
this.ws.ping();
|
||||||
this.lastPing = Date.now();
|
this.lastPing = Date.now();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user