Closed ChaitanyaYeole02 closed 1 year ago
I received this error, when I connected a lot of CP in only one worker
If you think this is a bug in occp_asgi then attach the traceback and example code in order to reproduce the error.
I will explain the situation here:
I connected 4 CPs to my server and reconnected one. All 4 got disconnected and the one I connected is the one which called on_connect
function and the other 3 chargers are sending messages to the router but not calling on_connect
.
Traceback (most recent call last):
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 225, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "C:\Users\s******5\PycharmProjects\websocket\ocpp_asgi\app.py", line 91, in __call__
await self.handler(scope, receive, send)
File "C:\Users\s******5\PycharmProjects\websocket\ocpp_asgi\app.py", line 118, in handler
event = await receive()
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 336, in asgi_receive
data = await self.recv()
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\websockets\legacy\protocol.py", line 551, in recv
await asyncio.wait(
File "C:\Users\s******5\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 382, in wait
fs = {ensure_future(f, loop=loop) for f in fs}
File "C:\Users\s******5\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 382, in <setcomp>
fs = {ensure_future(f, loop=loop) for f in fs}
File "C:\Users\s******5\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 615, in ensure_future
return _ensure_future(coro_or_future, loop=loop)
File "C:\Users\s******5\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 630, in _ensure_future
raise TypeError('An asyncio.Future, a coroutine or an awaitable '
It is calling on_connect but getting this error
[run_asgi - 229] Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 225, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "C:\Users\s******5\PycharmProjects\websocket\ocpp_asgi\app.py", line 92, in __call__
await self.handler(scope, receive, send)
File "C:\Users\s******5\PycharmProjects\websocket\ocpp_asgi\app.py", line 137, in handler
await send({"type": "websocket.accept"})
File "C:\Users\s******5\PycharmProjects\websocket\venv310\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 312, in asgi_send
raise RuntimeError(msg % message_type)
RuntimeError: Expected ASGI message 'websocket.send' or 'websocket.close', but got 'websocket.accept'.
Even though it looks like ocpp_asgi/app.py is for some reason sending non-expected ASGI event I can't reproduce the issue.
In branch https://github.com/villekr/ocpp-asgi/pull/17 I updated the test code so that it's easy to create test Charging Stations and disconnect and connect them freely. But couldn't reproduce this kind of problem.
Closing. Please reopen by attaching example code that this issue can be reproduced.
Hello @villekr , I am facing a problem when the on_disconnect event is called and still my CP is sending messages to our CS. I am thinking of closing the connection manually inside on_disconect