+ _startWebSocketPing(): void {
+ const webSocketPingInterval: number = this._getConfigurationKey('WebSocketPingInterval') ? Utils.convertToInt(this._getConfigurationKey('WebSocketPingInterval').value) : 0;
+ if (webSocketPingInterval > 0 && !this._webSocketPingSetInterval) {
+ this._webSocketPingSetInterval = setInterval(() => {
+ if (this._wsConnection?.readyState === WebSocket.OPEN) {
+ this._wsConnection.ping((): void => { });
+ }
+ }, webSocketPingInterval * 1000);
+ logger.info(this._logPrefix() + ' WebSocket ping started every ' + Utils.secondsToHHMMSS(webSocketPingInterval));
+ } else if (this._webSocketPingSetInterval) {
+ logger.info(this._logPrefix() + ' WebSocket ping every ' + Utils.secondsToHHMMSS(webSocketPingInterval) + ' already started');
+ } else {
+ logger.error(`${this._logPrefix()} WebSocket ping interval set to ${webSocketPingInterval ? Utils.secondsToHHMMSS(webSocketPingInterval) : webSocketPingInterval}, not starting the WebSocket ping`);
+ }
+ }
+
+ _stopWebSocketPing(): void {
+ if (this._webSocketPingSetInterval) {
+ clearInterval(this._webSocketPingSetInterval);
+ this._webSocketPingSetInterval = null;
+ }
+ }
+
+ _restartWebSocketPing(): void {
+ // Stop WebSocket ping
+ this._stopWebSocketPing();
+ // Start WebSocket ping
+ this._startWebSocketPing();
+ }
+