diff --git a/juju/client/connection.py b/juju/client/connection.py index 2a36ace18..5903cde70 100644 --- a/juju/client/connection.py +++ b/juju/client/connection.py @@ -436,7 +436,9 @@ async def close(self, to_reconnect=False): async def _recv(self, request_id): if not self.is_open: - raise websockets.exceptions.ConnectionClosed(0, 'websocket closed') + raise websockets.exceptions.ConnectionClosed( + websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE, + 'websocket closed')) try: return await self.messages.get(request_id) except GeneratorExit: @@ -604,7 +606,8 @@ async def rpc(self, msg, encoder=None): if self.monitor.status == Monitor.DISCONNECTED: # closed cleanly; shouldn't try to reconnect raise websockets.exceptions.ConnectionClosed( - 0, 'websocket closed') + websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE, + 'websocket closed')) try: await self._ws.send(outgoing) break