lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
275 stars 126 forks source link

Don't allow multiple connections with the same ID #92

Closed michaelbeaumont closed 3 years ago

michaelbeaumont commented 3 years ago

Multiple connections to the same URL would break things, the timeout exists for the case of a quick disconnect + reconnect, where the disconnection isn't yet registered. The timeout, the CloseMessage are all just one way to handle this case.

lorenzodonini commented 3 years ago

Sorry for taking so long to review this. I see the issue and I like the solution, but what would you think of a "simpler" approach? When the new connection is opened and there is still an open connection with the same ID, the new one is simply closed with code 1008 (like you suggested), and the client will just have to try again after a timeout. It would save us the trouble of using a dedicated timer/channel and it would be a no-brainer.

michaelbeaumont commented 3 years ago

Sure, that's an option. I'll update