From d7caa810421e0ca485fe7cca35ff02235151690a Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 12 Dec 2025 21:32:08 +0100 Subject: [PATCH] Add data channel state monitoring and increase send delay - Increase delay to 500ms before sending identify - Monitor channel state before sending - Log bufferedAmount after send - Add onclose handler for debugging --- test-connect.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test-connect.js b/test-connect.js index 405b4d3..6a90c3d 100644 --- a/test-connect.js +++ b/test-connect.js @@ -93,8 +93,14 @@ async function main() { console.log(' ✓ Data channel opened!') console.log(` Data channel state: ${dc.readyState}`) - // Small delay to ensure both sides are ready + // Longer delay to ensure both sides are ready setTimeout(() => { + console.log(` Data channel state before send: ${dc.readyState}`) + if (dc.readyState !== 'open') { + console.error(` ❌ Data channel not open: ${dc.readyState}`) + return + } + // Send identify message (demo protocol) console.log(`📤 Sending identify message...`) const identifyMsg = JSON.stringify({ @@ -103,8 +109,17 @@ async function main() { }) console.log(` Message:`, identifyMsg) dc.send(identifyMsg) - console.log(` ✓ Identify message sent`) - }, 100) + console.log(` ✓ Identify message sent, bufferedAmount: ${dc.bufferedAmount}`) + }, 500) + } + + dc.onclose = () => { + console.log(' ❌ Data channel closed!') + } + + dc.onerror = (error) => { + console.error('❌ Data channel error:', error) + process.exit(1) } dc.onmessage = (event) => {