OCPP: dispatch RemoteStartTransaction asynchronously to avoid WebSocket deadlock (#29838)
This commit is contained in:
parent
47132a4af2
commit
e07838bb8e
1 changed files with 9 additions and 1 deletions
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue