Closed dwibudut closed 1 month ago
Hi @lorenzodonini
Just compare the ocpp1.6/central_system.go
and ocpp2.0.1/csms.go
I found a missed in ocpp2.0.1/csms.go
Here the difference
After adding the missed, call callback in CSMS is work normal. That is by Dequeue
all pending queue callbacks.
...
func (cs *csms) SetChargingStationDisconnectedHandler(handler ChargingStationConnectionHandler) {
cs.server.SetDisconnectedClientHandler(func(chargingStation ws.Channel) {
for cb, ok := cs.callbackQueue.Dequeue(chargingStation.ID()); ok; cb, ok = cs.callbackQueue.Dequeue(chargingStation.ID()) {
err := ocpp.NewError(ocppj.GenericError, "client disconnected, no response received from client", "")
cb(nil, err)
}
handler(chargingStation)
})
}
...
I will create a PR to solve this missed.
OCPP version: [ ] 1.6 [x] 2.0.1
I'm submitting a ...
[x] bug report [ ] feature request
Current behavior:
Getting call to the obsolete callback even the response is for a new request
Steps to reproduce:
TriggerMessage.req
feature:TriggerMessage.conf
to CSMSTriggerMessage.conf
to new/second request (with requestId3052395016
) :The result is CSMS getting the response of second message, but call the callback response of requestId
3052395016
is pointing to first/obsolete callback https://github.com/lorenzodonini/ocpp-go/blob/9f716f928b8a0e2bdd1f1b2c563486ec5620fe43/internal/callbackqueue/callbackqueue.go#L40-L62The
Dequeue
method always get the first queued callback even though it is already obsolete (or the first message request callback is still exists).Full log of test:
Other information:
I think it requires a uniqueId/requestId to relate with the callback on CallbackQueue but it looks complicated
cc: @lorenzodonini