question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to handle responses from the Backend

See original GitHub issue

I’m sorry if this sounds like a stupid question, but I’m just a hobby developer and kind of stuck here.

Regarding the classic example from the protocol (Authorize, StartTransaction, Authorize, StopTransaction), how can I handle the .conf responses from the charging stations ?

I have two seperate scripts as in the examples. The .req from the CP side works perfectly, but how can I handle the answer from the Charging Station ?

I initially thought on using @on(Action.BootNotification) to catch the call_result.BootNotification on CP side, but nothing happens.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
OrangeTuxcommented, Dec 23, 2021

The @after() is a post request hook. It’s triggered by requests, not responses. Similar to the @on() decorator, that is only triggered by requests too, not responses. Therefore, the suggestion from @proelke doesn’t work.

Your code, @c0nr3f , works and makes sense to me. Although I suggest a small change: replace asyncio.create_task(self.send_authorize()) with await self.send_authorize().

Using a fire and forget strategy of tasks using asyncio.create_task() is dangerous. Errors raised during it’s execution don’t bubble up to the caller.

0reactions
c0nr3fcommented, Dec 22, 2021

But then we are back at the question, how to handle the response from the backend. How would you code an Authorize call as a reaction to the BootNotification.conf ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Tips on API Responses for Backend Developers
Always return objects, consider not using JSON, do not filter out null values. Let's delve into these 3 tips on API responses for...
Read more >
Fantastic Requests and How to Handle Them — A Backend ...
In our story, this works out fine and he receives the appropriate success answer (200 in real life, or a similar Success response)....
Read more >
Dealing with Delayed Response from Backend - Forums - IBM
The case where one of back-end system is slow in responding to high request volumes can be addressed using SLM. You can fix...
Read more >
How Does the Frontend Communicate with the Backend?
If a browser requests something like http://example.com/style.css , this is usually handled by the web server (like Nginx) of the backend. The request...
Read more >
How the Web Works, HTTP Request/Response Cycle
Define the 'Vocabulary' of the web; Describe the Request/Response Cycle at a high level; Describe the parts ... The process would look something...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found