diff --git a/neode-ui/mock-backend.js b/neode-ui/mock-backend.js index 2ed54951..abaa990b 100755 --- a/neode-ui/mock-backend.js +++ b/neode-ui/mock-backend.js @@ -893,7 +893,14 @@ app.post('/rpc/v1', (req, res) => { return res.json({ result: { success: true } }) } + case 'node-messages-received': + case 'node.messages': + case 'node.notifications': { + return res.json({ result: [] }) + } + default: { + console.log(`[RPC] Unknown method: ${method}`) return res.json({ error: { code: -32601, @@ -934,12 +941,23 @@ wss.on('connection', (ws, req) => { } catch (err) { console.error('[WebSocket] Ping error:', err) clearInterval(pingInterval) + clearInterval(heartbeatInterval) } } else { clearInterval(pingInterval) + clearInterval(heartbeatInterval) } }, 30000) // Ping every 30 seconds + // Send periodic heartbeat data so clients don't think the connection is dead + const heartbeatInterval = setInterval(() => { + if (ws.readyState === 1) { + try { + ws.send(JSON.stringify({ rev: Date.now(), patch: [] })) + } catch { /* ignore */ } + } + }, 45000) // Every 45s (client expects data within 60s) + // Send initial data immediately try { ws.send(JSON.stringify({ @@ -968,12 +986,14 @@ wss.on('connection', (ws, req) => { ws.on('close', (code, reason) => { console.log('[WebSocket] Client disconnected', { code, reason: reason.toString() }) clearInterval(pingInterval) + clearInterval(heartbeatInterval) wsClients.delete(ws) }) ws.on('error', (error) => { console.error('[WebSocket Error]', error) clearInterval(pingInterval) + clearInterval(heartbeatInterval) wsClients.delete(ws) }) })