-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-n8n-connection.js
More file actions
69 lines (58 loc) · 2 KB
/
Copy pathtest-n8n-connection.js
File metadata and controls
69 lines (58 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
// Test script to verify N8N can connect to thumbnail service
const http = require('http');
const testConnection = (hostname, port, path = '/health') => {
return new Promise((resolve) => {
const options = {
hostname,
port,
path,
method: 'GET',
timeout: 5000
};
const req = http.request(options, (res) => {
let data = '';
res.on('data', (chunk) => data += chunk);
res.on('end', () => {
console.log(`✅ ${hostname}:${port}${path} - Status: ${res.statusCode}`);
try {
const response = JSON.parse(data);
console.log(` Response: ${JSON.stringify(response, null, 2)}`);
} catch (e) {
console.log(` Raw response: ${data}`);
}
resolve(true);
});
});
req.on('error', (e) => {
console.log(`❌ ${hostname}:${port}${path} - Error: ${e.message}`);
resolve(false);
});
req.on('timeout', () => {
console.log(`⏰ ${hostname}:${port}${path} - Timeout after 5s`);
req.destroy();
resolve(false);
});
req.end();
});
};
const runTests = async () => {
console.log('🧪 Testing connections to thumbnail service...\n');
console.log('📝 Note: To test from N8N container, run:');
console.log(' docker exec -it n8n-n8n-1 node /path/to/test-n8n-connection.js\n');
const tests = [
{ hostname: 'localhost', port: 3000 },
{ hostname: 'yiku-thumbnail', port: 3000 },
{ hostname: '172.18.0.1', port: 3000 },
{ hostname: '147.93.59.152', port: 3000 }
];
for (const test of tests) {
await testConnection(test.hostname, test.port);
console.log(''); // Empty line for readability
}
console.log('🎯 Test completed!');
console.log('\n🔍 To test from N8N container:');
console.log(' 1. Copy this file to N8N container: docker cp test-n8n-connection.js n8n-n8n-1:/home/node/');
console.log(' 2. Run test: docker exec -it n8n-n8n-1 node test-n8n-connection.js');
};
runTests().catch(console.error);