ocpp icon indicating copy to clipboard operation
ocpp copied to clipboard

How to handle unproper connection of CP?

Open eslavko opened this issue 3 years ago • 4 comments

Hello... Just wonder how to proper maintain connection. When CP connects to server it should 1st send BootNotification. But I have station that can send StatusNotification (or others) before BootNotification. So how to proper handle that? I assume that all traffic before BootNotification should be suspended or connection colsed/refused.

eslavko avatar Apr 02 '21 12:04 eslavko

Hey @eslavko So the BootNotification is sent after an start-up, booting or rebooting process. Check section 4.2 on OCPP 1.6, so I believe not necessarily needs to be the first message after the charger connects to Central System.

  • What happens if you proceed? Does any error appear from your implementation?

laysauchoa avatar Apr 10 '21 13:04 laysauchoa

Hello... Actually I want to be little more paranoic and want to allow just known stations to connect. So the URL must match with the known data from boot notification data. As data is not available when connection is made I just want to reject all traffic until got BootNottification. After that if data here is expected one will allow all other functionality or reject station and droop connection.

eslavko avatar Apr 10 '21 15:04 eslavko

@eslavko can you the wait for certain amount of time for the BootNotification then if you do not receive after this amount of time, you can close/refuse the connection? Would this work in your case? Just an idea! :)

laysauchoa avatar Apr 10 '21 17:04 laysauchoa

Could work. For now I changed source charge_point.py and modify start routilne with this: `#----------------------added by CAA self.bootNotify=False self.Exit=False async def start(self): while self.Exit==False: message = await self._connection.recv() if self.bootNotify==True or "BootNotification" in message: LOGGER.info('%s: receive message %s', self.id, message) await self.route_message(message) #LOGGER.info('%s: Closing connection.', self.id) await self._connection.close() #LOGGER.info('%s: Connection closed. %s' % (self.id,self.Exit)) #----------------------

` So when station is connected all message different of BootNotification is not routed. When BootNotification is received and data are valid I set bootNotify=True and all mesage from this time will pass.

eslavko avatar Apr 11 '21 06:04 eslavko