Skip to content

Commit fdd0329

Browse files
committed
reject globalAwareness connections gracefully, fixes latency
1 parent 24328f2 commit fdd0329

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

jupyter_rtc_core/websockets/yroom_ws.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def prepare(self):
4242

4343
# TODO: remove this once globalawareness is implemented
4444
if self.room_id == "JupyterLab:globalAwareness":
45-
raise HTTPError(404)
45+
self.close(1011)
46+
return
4647

4748
# Verify the file ID contained in the room ID points to a valid file.
4849
fileid = self.room_id.split(":")[-1]
@@ -52,6 +53,11 @@ def prepare(self):
5253

5354

5455
def open(self, *_, **__):
56+
# TODO: remove this later
57+
if self.room_id == "JupyterLab:globalAwareness":
58+
self.close(1011)
59+
return
60+
5561
# Create the YRoom
5662
yroom = self.yroom_manager.get_room(self.room_id)
5763
if not yroom:
@@ -63,10 +69,18 @@ def open(self, *_, **__):
6369

6470

6571
def on_message(self, message: bytes):
72+
# TODO: remove this later
73+
if self.room_id == "JupyterLab:globalAwareness":
74+
return
75+
6676
# Route all messages to the YRoom for processing
6777
self.yroom.add_message(self.client_id, message)
6878

6979

7080
def on_close(self):
71-
self.log.info("WEBSOCKET CLOSED")
81+
# TODO: remove this later
82+
if self.room_id == "JupyterLab:globalAwareness":
83+
return
84+
85+
self.log.info(f"Closed Websocket to client '{self.client_id}'.")
7286
self.yroom.clients.remove(self.client_id)

0 commit comments

Comments
 (0)