Skip to content

Commit 963f13f

Browse files
committed
Restore display of close code and reason.
Fix #1591.
1 parent 667e418 commit 963f13f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/websockets/__main__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
except ImportError: # Windows has no `readline` normally
1313
pass
1414

15+
from .frames import Close
1516
from .sync.client import ClientConnection, connect
1617
from .version import version as websockets_version
1718

@@ -150,7 +151,10 @@ def main() -> None:
150151
except (KeyboardInterrupt, EOFError): # ^C, ^D
151152
stop.set()
152153
websocket.close()
153-
print_over_input("Connection closed.")
154+
155+
assert websocket.close_code is not None and websocket.close_reason is not None
156+
close_status = Close(websocket.close_code, websocket.close_reason)
157+
print_over_input(f"Connection closed: {close_status}.")
154158

155159
thread.join()
156160

0 commit comments

Comments
 (0)