From 8f06121d8fecd214f24635962f6e871199dd97c4 Mon Sep 17 00:00:00 2001 From: n9k Date: Tue, 14 Jun 2022 00:34:24 +0000 Subject: [PATCH] WS: ping before init --- anonstream/websocket.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/anonstream/websocket.py b/anonstream/websocket.py index 38226c8..d9bb0cc 100644 --- a/anonstream/websocket.py +++ b/anonstream/websocket.py @@ -17,7 +17,8 @@ from anonstream.utils.websocket import parse_websocket_data, Malformed, WS CONFIG = current_app.config async def websocket_outbound(queue, user): - payload = { + await websocket.send_json({'type': 'ping'}) + await websocket.send_json({ 'type': 'init', 'nonce': generate_nonce(), 'title': await get_stream_title(), @@ -31,9 +32,7 @@ async def websocket_outbound(queue, user): 'scrollback': CONFIG['MAX_CHAT_SCROLLBACK'], 'digest': get_random_captcha_digest_for(user), 'pingpong': CONFIG['TASK_BROADCAST_PING'], - } - await websocket.send_json(payload) - await websocket.send_json({'type': 'ping'}) + }) while True: payload = await queue.get() if payload['type'] == 'close':