OCPP: dispatch RemoteStartTransaction asynchronously to avoid WebSocket deadlock (#29838)

This commit is contained in:
andig 2026-05-12 13:39:23 +02:00 • committed by GitHub
parent 47132a4af2
commit e07838bb8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,7 +39,15 @@ func (conn *Connector) OnStatusNotification(request *core.StatusNotificationRequ
if conn.isWaitingForAuth() {
if conn.remoteIdTag != "" {
conn.RemoteStartTransactionRequest(conn.remoteIdTag)
// dispatch asynchronously: RemoteStartTransactionRequest issues a
// synchronous CS→CP request whose response is read by this same
// goroutine, so a blocking call would deadlock the WebSocket read
// loop (cf. ocpp_test_handler.go).
go func(idTag string) {
if err := conn.RemoteStartTransactionRequest(idTag); err != nil {
conn.log.ERROR.Printf("RemoteStartTransaction: %v", err)
}
}(conn.remoteIdTag)
} else {
conn.log.DEBUG.Printf("waiting for local authentication")
}