private evsesConfigurationHash!: string
private automaticTransactionGeneratorConfiguration?: AutomaticTransactionGeneratorConfiguration
private ocppIncomingRequestService!: OCPPIncomingRequestService
+ private acceptedEventListenerRegistered: boolean
private readonly messageBuffer: Set<string>
private configuredSupervisionUrl!: URL
private autoReconnectRetryCount: number
this.started = false
this.starting = false
this.stopping = false
+ this.acceptedEventListenerRegistered = false
this.wsConnection = null
this.autoReconnectRetryCount = 0
this.index = index
this.ocppConfiguration = this.getOcppConfiguration()
this.initializeOcppConfiguration()
this.initializeOcppServices()
- this.once(ChargingStationEvents.accepted, () => {
- this.startMessageSequence().catch(error => {
- logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error)
- })
- })
if (this.stationInfo.autoRegister === true) {
this.bootNotificationResponse = {
currentTime: new Date(),
return ocppConfiguration
}
+ private registerAcceptedEventListener (): void {
+ this.once(ChargingStationEvents.accepted, () => {
+ this.startMessageSequence().catch(error => {
+ logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error)
+ })
+ this.acceptedEventListenerRegistered = false
+ })
+ this.acceptedEventListenerRegistered = true
+ }
+
private async onOpen (): Promise<void> {
if (this.isWebSocketConnectionOpened()) {
logger.info(
this.stationInfo?.registrationMaxRetries === -1)
)
}
+ if (!this.acceptedEventListenerRegistered) {
+ this.registerAcceptedEventListener()
+ }
if (this.isRegistered()) {
this.emit(ChargingStationEvents.registered)
if (this.inAcceptedState()) {
code
)}' and reason '${reason.toString()}'`
)
- this.started && this.reconnect().catch(Constants.EMPTY_FUNCTION)
+ this.started &&
+ this.reconnect().catch(error =>
+ logger.error(`${this.logPrefix()} Error while reconnecting:`, error)
+ )
break
}
this.emit(ChargingStationEvents.updated)