private ocppIncomingRequestService!: OCPPIncomingRequestService
private readonly messageBuffer: Set<string>
private configuredSupervisionUrl!: URL
- private autoReconnectRetryCount: number
+ private wsConnectionRetried: boolean
+ private wsConnectionRetryCount: number
private templateFileWatcher!: FSWatcher | undefined
private templateFileHash!: string
private readonly sharedLRUCache: SharedLRUCache
- private webSocketPingSetInterval?: NodeJS.Timeout
+ private wsPingSetInterval?: NodeJS.Timeout
private readonly chargingStationWorkerBroadcastChannel: ChargingStationWorkerBroadcastChannel
private flushMessageBufferSetInterval?: NodeJS.Timeout
this.starting = false
this.stopping = false
this.wsConnection = null
- this.autoReconnectRetryCount = 0
+ this.wsConnectionRetried = false
+ this.wsConnectionRetryCount = 0
this.index = index
this.templateFile = templateFile
this.connectors = new Map<number, ConnectorStatus>()
})
this.on(ChargingStationEvents.accepted, () => {
this.startMessageSequence(
- this.autoReconnectRetryCount > 0
+ this.wsConnectionRetried
? true
: this.getAutomaticTransactionGeneratorConfiguration()?.stopAbsoluteDuration
).catch(error => {
logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error)
})
+ this.wsConnectionRetried = false
})
this.on(ChargingStationEvents.disconnected, () => {
try {
})`
)
}
- this.autoReconnectRetryCount = 0
+ this.wsConnectionRetryCount = 0
this.emit(ChargingStationEvents.updated)
} else {
logger.warn(
code
)}' and reason '${reason.toString()}'`
)
- this.autoReconnectRetryCount = 0
+ this.wsConnectionRetryCount = 0
break
// Abnormal close
default:
getConfigurationKey(this, StandardParametersKey.WebSocketPingInterval)?.value
)
: 0
- if (webSocketPingInterval > 0 && this.webSocketPingSetInterval == null) {
- this.webSocketPingSetInterval = setInterval(() => {
+ if (webSocketPingInterval > 0 && this.wsPingSetInterval == null) {
+ this.wsPingSetInterval = setInterval(() => {
if (this.isWebSocketConnectionOpened()) {
this.wsConnection?.ping()
}
webSocketPingInterval
)}`
)
- } else if (this.webSocketPingSetInterval != null) {
+ } else if (this.wsPingSetInterval != null) {
logger.info(
`${this.logPrefix()} WebSocket ping already started every ${formatDurationSeconds(
webSocketPingInterval
}
private stopWebSocketPing (): void {
- if (this.webSocketPingSetInterval != null) {
- clearInterval(this.webSocketPingSetInterval)
- delete this.webSocketPingSetInterval
+ if (this.wsPingSetInterval != null) {
+ clearInterval(this.wsPingSetInterval)
+ delete this.wsPingSetInterval
}
}
private async reconnect (): Promise<void> {
if (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.autoReconnectRetryCount < this.stationInfo!.autoReconnectMaxRetries! ||
+ this.wsConnectionRetryCount < this.stationInfo!.autoReconnectMaxRetries! ||
this.stationInfo?.autoReconnectMaxRetries === -1
) {
- ++this.autoReconnectRetryCount
+ this.wsConnectionRetried = true
+ ++this.wsConnectionRetryCount
const reconnectDelay =
this.stationInfo?.reconnectExponentialDelay === true
- ? exponentialDelay(this.autoReconnectRetryCount)
+ ? exponentialDelay(this.wsConnectionRetryCount)
: secondsToMilliseconds(this.getConnectionTimeout())
const reconnectDelayWithdraw = 1000
const reconnectTimeout =
)
await sleep(reconnectDelay)
logger.error(
- `${this.logPrefix()} WebSocket connection retry #${this.autoReconnectRetryCount.toString()}`
+ `${this.logPrefix()} WebSocket connection retry #${this.wsConnectionRetryCount.toString()}`
)
this.openWSConnection(
{
} else if (this.stationInfo?.autoReconnectMaxRetries !== -1) {
logger.error(
`${this.logPrefix()} WebSocket connection retries failure: maximum retries reached (${
- this.autoReconnectRetryCount
+ this.wsConnectionRetryCount
}) or retries disabled (${this.stationInfo?.autoReconnectMaxRetries})`
)
}