Added log handling for failed phone connection to the gateway
This commit is contained in:
1 parent
4866f14231
commit
27dc7917f2
1 file changed
+9
-1
@@ -483,12 +483,18 @@ class HttpServer:
|
|||||||
# Register BEFORE the replay so a frame appended in between is
|
# Register BEFORE the replay so a frame appended in between is
|
||||||
# fanned out to us (and de-duped by cursor below) instead of lost.
|
# fanned out to us (and de-duped by cursor below) instead of lost.
|
||||||
self._add_sub(sub)
|
self._add_sub(sub)
|
||||||
|
reason = "eof"
|
||||||
try:
|
try:
|
||||||
handler.send_response(200)
|
handler.send_response(200)
|
||||||
handler.send_header("Content-Type", "text/event-stream")
|
handler.send_header("Content-Type", "text/event-stream")
|
||||||
handler.send_header("Cache-Control", "no-cache")
|
handler.send_header("Cache-Control", "no-cache")
|
||||||
handler.send_header("X-Accel-Buffering", "no")
|
handler.send_header("X-Accel-Buffering", "no")
|
||||||
handler.end_headers()
|
handler.end_headers()
|
||||||
|
# INFO (not DEBUG like the per-request log): the stream
|
||||||
|
# lifecycle is the primary "is the device connected?" signal
|
||||||
|
# for debugging flaky links — a gap here is invisible at the
|
||||||
|
# gateway's default log level.
|
||||||
|
logger.info("android: SSE stream opened: %s (cursor=%d)", device_id, cursor)
|
||||||
# 1. Catch-up from the outbox (id = cursor; the envelope also
|
# 1. Catch-up from the outbox (id = cursor; the envelope also
|
||||||
# carries the cursor for the app's push dedupe).
|
# carries the cursor for the app's push dedupe).
|
||||||
max_cursor = cursor
|
max_cursor = cursor
|
||||||
@@ -515,6 +521,7 @@ class HttpServer:
|
|||||||
self._write_raw(handler, ": hb\n\n")
|
self._write_raw(handler, ": hb\n\n")
|
||||||
continue
|
continue
|
||||||
if item is _STOP:
|
if item is _STOP:
|
||||||
|
reason = "stopped"
|
||||||
break
|
break
|
||||||
c, data = item
|
c, data = item
|
||||||
if c is not None and c <= max_cursor:
|
if c is not None and c <= max_cursor:
|
||||||
@@ -523,8 +530,9 @@ class HttpServer:
|
|||||||
except (BrokenPipeError, ConnectionResetError, OSError):
|
except (BrokenPipeError, ConnectionResetError, OSError):
|
||||||
# Client went away mid-stream: normal (the app reconnects with
|
# Client went away mid-stream: normal (the app reconnects with
|
||||||
# Last-Event-ID and catches up from the outbox).
|
# Last-Event-ID and catches up from the outbox).
|
||||||
pass
|
reason = "client-gone"
|
||||||
finally:
|
finally:
|
||||||
|
logger.info("android: SSE stream closed: %s (%s)", device_id, reason)
|
||||||
self._remove_sub(sub)
|
self._remove_sub(sub)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in new issue
Block a user