2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-10-20 06:35:33 +00:00

Persist error during streaming

Also, do not start input tasks until handshake actually completese.
This commit is contained in:
Jarrod Johnson
2026-10-13 10:21:36 -04:00
parent 5f4b41c501
commit 25ecf590dd
2 changed files with 13 additions and 7 deletions
+9 -5
View File
@@ -681,6 +681,8 @@ def draw_text(text, width, height):
cursor_left(len(text))
def draw_image(bindata, width, height, doscale=True):
if not bindata:
return
imageformat = os.environ.get('CONFLUENT_IMAGE_PROTOCOL', 'kitty')
if doscale and Image and width:
binfile = io.BytesIO()
@@ -1110,6 +1112,7 @@ async def do_vnc(node, url, outputfile=None):
break
except vnc.VNCReceiverTerminated:
# The VNC receiver task has terminated unexpectedly
draw_node(node, None, 'Video not connected', '', cwidth, cheight)
break
retries = 5
# Save as PNG using PIL/pillow
@@ -1124,12 +1127,13 @@ async def do_vnc(node, url, outputfile=None):
if not streaming:
keeprunning = False
break
except ValueError as e:
except Exception as e:
draw_node(node, None, str(e), '', cwidth, cheight)
retries -= 1
if retries <= 0:
keeprunning = False
sys.stderr.write(f'VNC connection for node {node} failed with error: {e}\n')
if not streaming:
retries -= 1
if retries <= 0:
keeprunning = False
#sys.stderr.write(f'VNC connection for node {node} failed with error: {e}\n')
await asyncio.sleep(1)
+4 -2
View File
@@ -92,13 +92,15 @@ class VNCClient:
self.copytext = None
self._updating = True
self.decompressor = zlib.decompressobj()
await self._do_vnc_handshake()
self._input_queue = asyncio.Queue()
self._input_task = asyncio.create_task(self._input_worker())
await self._do_vnc_handshake()
return self
async def _input_worker(self):
while True:
if self.receiver is not None and self.receiver.done():
break
keys, modifierkeys = await self._input_queue.get()
payload = ByteStream()
for modkey in (modifierkeys or []):
@@ -163,7 +165,7 @@ class VNCClient:
async def _do_vnc_handshake(self):
rfbver = await self.reader.readline()
if not rfbver:
raise Exception('Connection failed to VNC')
raise Exception('Video not connected')
if not rfbver.startswith(b'RFB 003.008'):
self.writer.close()
await self.writer.wait_closed()