lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
277 stars 126 forks source link

Parses an OCPP-J message,Occurrence anomaly #267

Closed Kinrosslong closed 8 months ago

Kinrosslong commented 8 months ago

Hello, this is the first time for me to submit an issue on github, please forgive me if it is not good or not standard. I encountered an exception message parsing error while using the repackage, which caused my service to crash. The error was reported in the ocppj/ocppj.go file ParseMessage() method. If the device sends [3, "",{"fileName": "diagnostics_file2.log"}] A message command such as this causes the CALL_RESULT to parse the request, Ok: = pendingRequestState. GetPendingRequest (uniqueId) in the request is nil, causing collapse program exit.

xBlaz3kx commented 8 months ago

Hi @Kinrosslong,

it would help if you added a whole stack trace. From the description, it seems like the charge point does not send a unique request ID, so the central system isn't able to respond to the request.

[3, "",{"fileName": "diagnostics_file2.log"}] - The second element in the array is missing, should be something like "100124".

lorenzodonini commented 8 months ago

Empty message identifiers are not allowed.

I just merged a fix to throw an early error in case an empty string is ever encountered for that field. Your service shouldn't crash anymore but instead return the following error: Invalid unique ID, cannot be empty.

Kinrosslong commented 5 months ago

ok

lorenzodonini @.***> 于2024年4月3日周三 00:50写道:

Empty message identifiers are not allowed.

I just merged a fix to throw an early error in case an empty string is ever encountered for that field. Your service shouldn't crash anymore but instead return the following error: Invalid unique ID, cannot be empty.

— Reply to this email directly, view it on GitHub https://github.com/lorenzodonini/ocpp-go/issues/267#issuecomment-2032564376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGFJQWD4TQ3L4QAEHVIZT3Y3LOT3AVCNFSM6AAAAABFSP3UP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZSGU3DIMZXGY . You are receiving this because you were mentioned.Message ID: @.***>

Kinrosslong commented 5 months ago

Yes is an error caused by the second parameter being empty. What I want to express is that some equipment manufacturers do not professionally empty the second parameter. The system reported an error. We should be able to guard against that. Thanks for your answers and good luck。

KK

Blaž Dular @.***> 于2024年4月2日周二 19:53写道:

Hi @Kinrosslong https://github.com/Kinrosslong,

it would help if you added a whole stack trace. From the description, it seems like the charge point does not send a unique request ID, so the central system isn't able to respond to the request.

[3, "",{"fileName": "diagnostics_file2.log"}] - The second element in the array is missing, should be something like "100124".

— Reply to this email directly, view it on GitHub https://github.com/lorenzodonini/ocpp-go/issues/267#issuecomment-2031841706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGFJQRVTVMVZ57DVWCMZATY3KL4PAVCNFSM6AAAAABFSP3UP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZRHA2DCNZQGY . You are receiving this because you were mentioned.Message ID: @.***>