Handle abnormal closure of websocket
This commit is contained in:
parent
49f84755f1
commit
a1ddb43ed0
1 changed files with 2 additions and 1 deletions
|
@ -3,6 +3,7 @@ from typing import Any, Coroutine, Dict
|
|||
from uuid import UUID
|
||||
|
||||
from websockets import ConnectionClosed
|
||||
from starlette.websockets import WebSocketDisconnect
|
||||
|
||||
from app.ocpp_proto.chargepoint import ChargePoint
|
||||
|
||||
|
@ -12,7 +13,7 @@ async def start(id: UUID, cp: ChargePoint):
|
|||
try:
|
||||
__active_connections[id] = cp
|
||||
await cp.start()
|
||||
except ConnectionClosed:
|
||||
except (ConnectionClosed, WebSocketDisconnect):
|
||||
logging.info("Charging station '%s' (%s) disconnected", cp.id, id)
|
||||
__active_connections.pop(id, None)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue