Skip to content

Commit 7b7579e

Browse files
committed
Pass websocket Close frame into ConnectionClosed
Fixes #989
1 parent 16149db commit 7b7579e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

juju/client/connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ async def close(self, to_reconnect=False):
470470

471471
async def _recv(self, request_id):
472472
if not self.is_open:
473-
raise websockets.exceptions.ConnectionClosed(0, 'websocket closed')
473+
raise websockets.exceptions.ConnectionClosed(
474+
websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE,
475+
'websocket closed'))
474476
try:
475477
return await self.messages.get(request_id)
476478
except GeneratorExit:
@@ -641,7 +643,8 @@ async def rpc(self, msg, encoder=None):
641643
if self.monitor.status == Monitor.DISCONNECTED:
642644
# closed cleanly; shouldn't try to reconnect
643645
raise websockets.exceptions.ConnectionClosed(
644-
0, 'websocket closed')
646+
websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE,
647+
'websocket closed'))
645648
try:
646649
await self._ws.send(outgoing)
647650
break

0 commit comments

Comments
 (0)