-
Hello there, my name is José Luis Bueno, I’m currently studying Software Engineering in Málaga, Spain. I’m developing a webapp that manages bookings and some sort of things related to electric chargers and I found your repo. Firstly, I want to thank you for your great work you did on this repository, it’s excellent and it’s helping me a lot and simplifying my webapp development. This webapp is for a subject based on teaching protocols so I needed to use OCPP and I found your implementation of ASGI based on OCPP. I got a (surely very dumb) question but I’ve been stuck trying different methods and I can only get errors from my app. What I want to do is to send a “ReserveNow” transaction. I got the following code on client_api.py: So it calls the following async method on my charging station (note: i’m using ocpp 201): In this method I call the central station to ask for the response of the transaction, here you have the function on provisioning_router.py: Once I execute the POST call in the client api I’m getting three errors on the central system console:
And if I check the charging station console: Finally, on the client API console I get a 504 timeout, obviously. Hope you can provide me some help to solve this problem. I’m only asked to implement a few methods but following thoroughly the OCPP documentation. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hi,
Nice to hear that you've found ocpp-asgi library useful.
I'd say your problem is in a way how you're handling ReserveNow event. When your charging station receives a request from csms (ReserveNow) then within on-handler the only thing you can send back to csms is the response for that request. Here you're making a request back to csms with await self.call(request). Furthermore, ReserveNow request can only be made by csms to charging station.
If you want to perform any additional work after responding back to csms request you can do that in @after handler.
br,
VK
…________________________________
From: José Luis Bueno ***@***.***>
Sent: Friday, March 31, 2023 20:33
To: villekr/ocpp-asgi ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [villekr/ocpp-asgi] Help on implementing AuthorizeRequest (Discussion #24)
Hello there,
my name is José Luis Bueno, I’m currently studying Software Engineering in Málaga, Spain. I’m developing a webapp that manages bookings and some sort of things related to electric chargers and I found your repo.
Firstly, I want to thank you for your great work you did on this repository, it’s excellent and it’s helping me a lot and simplifying my webapp development.
This webapp is for a subject based on teaching protocols so I needed to use OCPP and I found your implementation of ASGI based on OCPP. I got a (surely very dumb) question but I’ve been stuck trying different methods and I can only get errors from my app.
What I want to do is to send a “ReserveNow” transaction. I got the following code on client_api.py:
[image]<https://user-images.githubusercontent.com/74137433/229190076-ec3d7a4d-ec1a-48aa-84c3-a1043a125c11.png>
So it calls the following async method on my charging station (note: i’m using ocpp 201):
[image]<https://user-images.githubusercontent.com/74137433/229190122-8e3d0e36-1163-4896-b910-5a123fbfe3eb.png>
In this method I call the central station to ask for the response of the transaction, here you have the function on provisioning_router.py:
[image]<https://user-images.githubusercontent.com/74137433/229190135-32ff9fb3-6f14-4faa-82c3-19a266afd213.png>
Once I execute the POST call in the client api I’m getting three errors on the central system console:
1. jsonschema.exceptions.ValidationError: Additional properties are not allowed ('status' was unexpected). I don’t really understand why I’m getting this error, I gotta attach the result of the reservation and it’s gotta be made by the central station.
2. ocpp.exceptions.FormatViolationError: FormatViolationError: Payload for Action is syntactically incorrect or structure for Action, {'cause': "Additional properties are not allowed ('status' was unexpected)”}. The same as above.
3. [on_receive - 201] Failure when processing message on_receive: e=TypeError('asdict() should be called on dataclass instances’). I don’t either understand this error, I’m providing the ReserveNowPayload dataclass, so why cant .asdict() be called?
And if I check the charging station console:
[_get_specific_response - 315] Ignoring response with unknown unique id: <CallError - unique_id=139c4075-372b-42e2-b36e-ac18bdb33f48, error_code=FormatViolation, error_description=Payload for Action is syntactically incorrect or structure for Action, error_details={'cause': "Additional properties are not allowed ('status' was unexpected)”}> It is the same as above, it’s spreading the exception.
Then I reveive a timeout exception.
Finally, on the client API console I get a 504 timeout, obviously.
Hope you can provide me some help to solve this problem. I’m only asked to implement a few methods but following thoroughly the OCPP documentation.
—
Reply to this email directly, view it on GitHub<#24>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGMWJCHW426TN6YLRE7S4LTW64IPFANCNFSM6AAAAAAWO55WDQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Your JWT token has no meaning in relation to OCPP communication. It's part of authenticating user in Client API. So yes, you probably will need to perform JWT token validation somehow in Client API (and this has nothing to do with OCPP, check e.g. FastAPI docs for instructions how to do that). After authentication you will likely have some form of authorization i.e. whether user is able to perform the specific request towards a specific charging station (once again this user authorization in Client API is something that's not related to OCPP communication as such). |
Beta Was this translation helpful? Give feedback.
Your JWT token has no meaning in relation to OCPP communication. It's part of authenticating user in Client API. So yes, you probably will need to perform JWT token validation somehow in Client API (and this has nothing to do with OCPP, check e.g. FastAPI docs for instructions how to do that). After authentication you will likely have some form of authorization i.e. whether user is able to perform the specific request towards a specific charging station (once again this user authorization in Client API is something that's not related to OCPP communication as such).