diff --git a/juju/client/connection.py b/juju/client/connection.py index ac8a7187..81527b79 100644 --- a/juju/client/connection.py +++ b/juju/client/connection.py @@ -447,7 +447,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: @@ -615,7 +617,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