|
|
@ -657,10 +657,12 @@ def stat_handler(end_event: threading.Event) -> None: |
|
|
|
def ws_proxy_recv(ws: WebSocket, local_sock: socket.socket, ssock: socket.socket, end_event: threading.Event, global_end_event: threading.Event) -> None: |
|
|
|
def ws_proxy_recv(ws: WebSocket, local_sock: socket.socket, ssock: socket.socket, end_event: threading.Event, global_end_event: threading.Event) -> None: |
|
|
|
while not (end_event.is_set() or global_end_event.is_set()): |
|
|
|
while not (end_event.is_set() or global_end_event.is_set()): |
|
|
|
try: |
|
|
|
try: |
|
|
|
data = ws.recv() |
|
|
|
r = select.select([ws], [], [], 10) |
|
|
|
if isinstance(data, str): |
|
|
|
if r[0]: |
|
|
|
data = data.encode("utf-8") |
|
|
|
data = ws.recv() |
|
|
|
local_sock.sendall(data) |
|
|
|
if isinstance(data, str): |
|
|
|
|
|
|
|
data = data.encode("utf-8") |
|
|
|
|
|
|
|
local_sock.sendall(data) |
|
|
|
except WebSocketTimeoutException: |
|
|
|
except WebSocketTimeoutException: |
|
|
|
pass |
|
|
|
pass |
|
|
|
except Exception: |
|
|
|
except Exception: |
|
|
@ -670,6 +672,7 @@ def ws_proxy_recv(ws: WebSocket, local_sock: socket.socket, ssock: socket.socket |
|
|
|
cloudlog.debug("athena.ws_proxy_recv closing sockets") |
|
|
|
cloudlog.debug("athena.ws_proxy_recv closing sockets") |
|
|
|
ssock.close() |
|
|
|
ssock.close() |
|
|
|
local_sock.close() |
|
|
|
local_sock.close() |
|
|
|
|
|
|
|
ws.close() |
|
|
|
cloudlog.debug("athena.ws_proxy_recv done closing sockets") |
|
|
|
cloudlog.debug("athena.ws_proxy_recv done closing sockets") |
|
|
|
|
|
|
|
|
|
|
|
end_event.set() |
|
|
|
end_event.set() |
|
|
|