-
Notifications
You must be signed in to change notification settings - Fork 149
🐛 Bug: Fix for OCPP Callback Queue Panic – Suggestion for Library Improvement #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey, great catch! However, I think the alternate approach might be the correct one, according to OCPP spec: ![]() Im not quite a 100% familiar with internals, but in this case a callback queue wouldnt even be needed, as we wouldnt actually be enforcing the message order/sequence. @lorenzodonini Could you asses this approach? |
Can you share the modified code? Thanks! |
📜 Description
Hi Lorenzo,
We've encountered a recurring panic in the OCPP library related to interface conversion errors when handling asynchronous responses. Here's a sample of the error:
This issue occurred on at least two charging stations—one of them crashed up to 20 times per day due to this.
Investigation
We reviewed previous issues on the GitHub repo, including:
TriggerMessage
andChange/GetConfiguration
are called concurrentlyWe traced the root cause to how the callback queue works in
callbackqueue.go
.Problem
The current implementation queues callbacks per
ClientID
, but dequeues them in FIFO order. This assumes that responses always arrive in sequence, which doesn't hold if a station delays or times out.In timeout scenarios:
Our Solution
We modified the
CallbackQueue
to maintain callbacks by bothClientID
and request type. That way, callbacks are queued and dequeued by type, avoiding mismatched handlers.This change has completely eliminated the panic in our environment.
Alternative Idea
A different approach could be queuing by message ID instead, and validating callback presence before handling.
Next Steps
Would you be open to reviewing this solution for inclusion in the library? I’m happy to submit a pull request if you think it’s a good direction.
Thanks again for your great work on this project!
Best regards,
👟 Reproduction steps
👍 Expected behavior
Callback queue dequeue should find answer by type to avoid panic, not only dequeuing the last message. A different approach could be queuing by message ID instead, and validating callback presence before handling.
👎 Actual Behavior
Callback queue dequeue uses last Message only, this leads to panic if that one doesn't match.
What OCPP version are you using?
Are you using any OCPP extensions?
release version
No response
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been found before?
The text was updated successfully, but these errors were encountered: