const WebSocket = require('ws'); console.log('Testing upload to remote 8083...'); const ws = new WebSocket('ws://146.56.248.142:8083/ws?password=wzw20040525'); let fileId = 'test_' + Date.now(); const testContent = Buffer.from('Hello Test 中文'); ws.on('open', () => { console.log('Connected, sending fileUploadStart with F:/xxx.txt...'); ws.send(JSON.stringify({ type: 'fileUploadStart', fileId: fileId, filename: 'F:/小问题.txt', totalChunks: 1, fileSize: testContent.length, requestId: 'req1' })); }); ws.on('message', (data, isBinary) => { if (isBinary) return; const msg = JSON.parse(data.toString()); console.log('Received:', msg.type); if (msg.type === 'fileUploadStart') { console.log('Session started, sending chunk...'); ws.send(JSON.stringify({ type: 'fileUploadChunk', fileId: fileId, chunkIndex: 0, data: testContent.toString('base64'), requestId: 'req2' })); } if (msg.type === 'fileUploadChunk') { console.log('Chunk sent, sending merge...'); ws.send(JSON.stringify({ type: 'fileUploadMerge', fileId: fileId, filename: 'F:/小问题.txt', totalChunks: 1, requestId: 'req3' })); } if (msg.type === 'fileUploadResult') { console.log('=== Upload Result:', msg.success ? 'SUCCESS' : 'FAILED', msg.error || ''); ws.close(); process.exit(0); } }); ws.on('error', err => console.error('Error:', err.message)); setTimeout(() => { console.log('Timeout'); process.exit(1); }, 15000);