Open andig opened 2 months ago
The disconnect handler is invoked in one of the following cases:
StopConnection
is invoked for that connectionIn all these cases no new connection will be accepted, until the old one was properly cleaned up. It is theoretically possible that your scheduler takes away CPU during execution in ChargePointDisconnected
and handles the new connection instead, leading to charge point connected
being logged before the disconnection. But this seems statistically unlikely, especially if we're talking about remote connections.
Do you have logs enabled in the websocket layer? I would expect to see this printed closed connection to %s"
before your ChargePointDisconnected
method is invoked. If you could show me some full logs (debug logs also welcome) I might be able to pinpoint the issue.
@lorenzodonini I think that is exactly what happened that what is theoretically possible happened, it would have been a bit cpu constrained while all this was going on at 3am. Is there a way to enable the websocket layer logs for ocpp go library from inside evcc?
Thats an evcc topic, not a library topic.
all these cases no new connection will be accepted, until the old one was properly cleaned up. It is theoretically possible that your scheduler takes away CPU during execution in ChargePointDisconnected and handles the new connection instead, leading to charge point connected being logged before the disconnection.
I don‘t see how this should happen if ocpp-go serialises that?
I don‘t see how this should happen if ocpp-go serialises that?
I was referring to the callback. The operation order is:
Any new connection is accepted on a dedicarted goroutine (that's how the http mux works), which at that point may run concurrently to your callback. So in theory CPU scheduler can cause some confusion, but again I do not believe this to be realistic.
Is there a way to enable the websocket layer logs for ocpp go library from inside evcc?
Yes, I suggest:
websocket.SetLogger(yourLogger) // Possibly with debug enabled (it will be spammy though)
See if this happens again and post the full logs here. If there really is a bug I didn't see yet, logs should make it more obvious.
So in theory CPU scheduler can cause some confusion, but again I do not believe this to be realistic.
Unless the callback is run in a go routine I don't see either how that should happen. It's still a bit problematic if we could have racy client-side callback code that cannot clearly be serialised. An alternative might be an "online status" api for the CS?
OCPP version: [x] 1.6 [ ] 2.0.1
I'm submitting a ...
[x] bug report [ ] feature request
Current behavior: In https://github.com/evcc-io/evcc/issues/15890 we're seeing that
ocpp16.ChargePointConnectionHandler
does not seem to always get triggered when a charge point reconnects.Expected behavior: Connect handler is always triggered after disconnect if a charge point re-establishes connection.
Instead, the order of disconnect and connect events seems arbitrary. Especially, there is no connect event after the last disconnect although the charge point is clearly still connected.
Notice that the connected/disconnected events are not paired in the log. If I should guess, it feels as if inflight sent messages might still trigger a disconnect even after the charge point has already reconnected?
Steps to reproduce: n/a
Related code:
The handler definition is quite straight forward:
Other information:
Notice that after
2024/09/04 03:14:26
change point is still sending and we can send, but there is noconnect
handler triggered: