OCPP: fix non-blocking RemoteStartTransaction#29210
Draft
Conversation
… handler When OnStatusNotification was called with Preparing status and remoteStart was enabled, RemoteStartTransactionRequest was called synchronously while holding conn.mu. This blocked the handler goroutine, which delayed the StatusNotification response back to the charge point. Some charge points (like Zaptec Go 2) may not process the incoming RemoteStartTransaction while still waiting for the StatusNotification response, causing a deadlock that only resolved after the OCPP timeout (1 minute). After the timeout, the RemoteStartTransaction was effectively lost. On subsequent vehicle connections, the same pattern repeated, preventing charging from starting. The fix launches RemoteStartTransactionRequest in a separate goroutine so that OnStatusNotification returns immediately, allowing the StatusNotification response to be sent back to the charge point promptly. This ensures the charge point is in the correct state to process the RemoteStartTransaction. Fixes #19965 Agent-Logs-Url: https://github.com/evcc-io/evcc/sessions/043e1352-8e68-4325-af8b-38c78575a2d7 Co-authored-by: premultiply <4681172+premultiply@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix remote start transaction issue for Zaptec Go 2
fix: make RemoteStartTransaction non-blocking in OnStatusNotification
Apr 18, 2026
There was a problem hiding this comment.
Pull request overview
Fixes an OCPP deadlock where OnStatusNotification synchronously triggered RemoteStartTransactionRequest, delaying the StatusNotification confirmation and preventing some charge points from processing the remote start until the OCPP timeout.
Changes:
- Make
RemoteStartTransactionRequestnon-blocking by dispatching it in a goroutine fromOnStatusNotification. - Add error logging for failed
RemoteStartTransactionRequestattempts. - Add unit tests covering “Preparing” status handling and remote-start-related state transitions across a stop/start cycle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
charger/ocpp/connector_core.go |
Avoids blocking the OCPP handler by running RemoteStartTransactionRequest asynchronously and logging failures. |
charger/ocpp/connector_test.go |
Adds tests for non-blocking status handling and re-entering “waiting for auth” after a completed transaction. |
Comment on lines
40
to
+46
| if conn.isWaitingForAuth() { | ||
| if conn.remoteIdTag != "" { | ||
| conn.RemoteStartTransactionRequest(conn.remoteIdTag) | ||
| if idTag := conn.remoteIdTag; idTag != "" { | ||
| go func() { | ||
| if err := conn.RemoteStartTransactionRequest(idTag); err != nil { | ||
| conn.log.ERROR.Printf("RemoteStartTransaction: %v", err) | ||
| } | ||
| }() |
Comment on lines
+170
to
+179
| done := make(chan struct{}) | ||
| go func() { | ||
| _, err := suite.conn.OnStatusNotification(req) | ||
| suite.NoError(err) | ||
| close(done) | ||
| }() | ||
|
|
||
| select { | ||
| case <-done: | ||
| // handler returned promptly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OnStatusNotificationcalledRemoteStartTransactionRequestsynchronously while holdingconn.mu. The ocpp-go library only sends theStatusNotificationresponse after the handler returns. Charge points like Zaptec Go 2 won't process the incomingRemoteStartTransactionuntil they receive that response — deadlock until the 1-minute OCPP timeout fires, at which point theRemoteStartTransactionis silently lost. First session works; every subsequent plug-in fails.charger/ocpp/connector_core.go: LaunchRemoteStartTransactionRequestin a goroutine so theStatusNotificationresponse is sent back immediately. Added error logging for failures.charger/ocpp/connector_test.go: AddedTestStatusNotificationPreparingNonBlocking(verifies handler returns promptly) andTestRemoteStartAfterReconnect(verifiesisWaitingForAuthstate across full connect→charge→disconnect→reconnect cycle).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
224.0.0.251REDACTED, pid is -1(packet block)If you need me to access, download, or install something from one of these locations, you can either: