From 3b3a667b96511c716ab09734266aa0f87932e5e6 Mon Sep 17 00:00:00 2001 From: deadRabbit Date: Sun, 22 Feb 2026 14:06:08 +0100 Subject: [PATCH] Add RDP debug logging and enable guacd debug level - docker-compose: override guacd command with -L debug flag so FreeRDP errors are visible in `docker logs mremotify-guacd-1` - rdp.ts: log RDP host/user, arg names, ready instruction, proxy-mode entry, and any error/disconnect instructions from guacd Co-Authored-By: Claude Sonnet 4.6 --- backend/src/websocket/rdp.ts | 18 ++++++++++++++++-- docker-compose.yml | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/src/websocket/rdp.ts b/backend/src/websocket/rdp.ts index 87956e6..f1c20f7 100644 --- a/backend/src/websocket/rdp.ts +++ b/backend/src/websocket/rdp.ts @@ -128,6 +128,8 @@ export async function rdpWebsocket(fastify: FastifyInstance) { return; } + fastify.log.info({ host: conn.host, port: conn.port, user: conn.username }, 'RDP: starting guacd handshake'); + try { // 1. Select protocol guacd.write(buildInstruction('select', conn.protocol)); @@ -135,6 +137,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) { // 2. Read args list from guacd const argsInstruction = await readInstruction(guacd, tcpBuf); const argNames = argsInstruction.slice(1); + fastify.log.info({ argNames }, 'RDP: guacd args list received'); const decryptedPassword = conn.encryptedPassword ? decrypt(conn.encryptedPassword) : ''; @@ -162,6 +165,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) { // 4. Read ready instruction const readyInstruction = await readInstruction(guacd, tcpBuf); + fastify.log.info({ readyInstruction }, 'RDP: guacd ready instruction received'); if (readyInstruction[0] !== 'ready') { throw new Error(`guacd handshake failed: expected 'ready', got '${readyInstruction[0]}'`); } @@ -185,12 +189,22 @@ export async function rdpWebsocket(fastify: FastifyInstance) { return; } + fastify.log.info({ uuid: readyInstruction[1] }, 'RDP: entering proxy mode'); + // --- Proxy mode --- guacd.on('data', (data: Buffer) => { - if (socket.readyState === WebSocket.OPEN) socket.send(data.toString('utf8')); + const text = data.toString('utf8'); + // Log the first message from guacd (usually an error or first instruction) + if (text.startsWith('5.error') || text.startsWith('10.disconnect')) { + fastify.log.warn({ guacdMsg: text.substring(0, 200) }, 'RDP: guacd sent error/disconnect'); + } + if (socket.readyState === WebSocket.OPEN) socket.send(text); }); - guacd.on('end', () => socket.close()); + guacd.on('end', () => { + fastify.log.info('RDP: guacd TCP connection ended'); + socket.close(); + }); guacd.on('error', (err) => { fastify.log.warn({ err }, 'guacd socket error'); socket.close(1011, err.message); diff --git a/docker-compose.yml b/docker-compose.yml index a27d444..4b545d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,8 @@ services: guacd: image: guacamole/guacd:1.5.4 restart: unless-stopped + # -L debug gives full FreeRDP error detail in `docker logs mremotify-guacd-1` + command: ["/bin/sh", "-c", "/usr/local/sbin/guacd -b 0.0.0.0 -l 4822 -f -L debug"] networks: - internal