Search code examples
python-3.xhttpwebsocketserverocpp

OCPP python server issue


I successfully tested the OCPP server by mobility house integrated with aiohttp API in local network. But now I am deploying the websocket server integrated with the HTTP API to Heroku and the Chargepoint script connects to the websocket server successfully and OCPP is happening but the HTTP endpoint is not reachable through curl through CMD by using the domain name URL. Actually this was working perfectly when I reached the HTTP server in local network using curl localhost:PORT command in CMD. But after deploying it is not.

On the server log It displays this:

heroku[router]: at=info method=POST path="/reset" host=ocpp.herokuapp.com request_id=43e705f-85c-48f-8273-002e5e9f3ed8 fwd="22.22.216.2" dyno=web.1 connect=0ms service=1ms status=400 bytes=242 protocol=http

As seen above the http connection is received but it is not doing anything.

On the CMD curl Output was this:

Failed to open Websocket connection: did not receive a valid http request.

I am using the below mentioned type of code for this:

https://github.com/mobilityhouse/ocpp/issues/86#issuecomment-620205346


Solution

  • Thanks people for any time you spent on this!

    I found the solution, I used fastAPI implementation on uvicorn and somehow the server worked nicely on heroku!!

    Thanks again