|
|
|
@ -38,6 +38,7 @@ LOCAL_PORT_WHITELIST = set([8022]) |
|
|
|
|
|
|
|
|
|
LOG_ATTR_NAME = 'user.upload' |
|
|
|
|
LOG_ATTR_VALUE_MAX_UNIX_TIME = int.to_bytes(2147483647, 4, sys.byteorder) |
|
|
|
|
RECONNECT_TIMEOUT_S = 70 |
|
|
|
|
|
|
|
|
|
dispatcher["echo"] = lambda s: s |
|
|
|
|
recv_queue: Any = queue.Queue() |
|
|
|
@ -385,6 +386,7 @@ def ws_proxy_send(ws, local_sock, signal_sock, end_event): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ws_recv(ws, end_event): |
|
|
|
|
last_ping = int(sec_since_boot() * 1e9) |
|
|
|
|
while not end_event.is_set(): |
|
|
|
|
try: |
|
|
|
|
opcode, data = ws.recv_data(control_frame=True) |
|
|
|
@ -393,9 +395,13 @@ def ws_recv(ws, end_event): |
|
|
|
|
data = data.decode("utf-8") |
|
|
|
|
recv_queue.put_nowait(data) |
|
|
|
|
elif opcode == ABNF.OPCODE_PING: |
|
|
|
|
Params().put("LastAthenaPingTime", str(int(sec_since_boot() * 1e9))) |
|
|
|
|
last_ping = int(sec_since_boot() * 1e9) |
|
|
|
|
Params().put("LastAthenaPingTime", str(last_ping)) |
|
|
|
|
except WebSocketTimeoutException: |
|
|
|
|
pass |
|
|
|
|
ns_since_last_ping = int(sec_since_boot() * 1e9) - last_ping |
|
|
|
|
if ns_since_last_ping > RECONNECT_TIMEOUT_S * 1e9: |
|
|
|
|
cloudlog.exception("athenad.wc_recv.timeout") |
|
|
|
|
end_event.set() |
|
|
|
|
except Exception: |
|
|
|
|
cloudlog.exception("athenad.ws_recv.exception") |
|
|
|
|
end_event.set() |
|
|
|
|