重现问题的步骤:
(在容器内)
const child_process = require('child_process');
console.time("Executed nc in ");
var output = child_process.spawnSync('nc', ['-w', '5', '<hostname of host with SSH>', 22, '<<<', '\0']).stdout.toString();
console.timeEnd("Executed nc in ");
console.log(output);
结果将包含执行nc in:XX ms ,我在10秒范围内看到XX。
当我在节点外的同一容器上运行netcat时, nc -w 5 [使用SSH的主机名] 22&lt;&lt;&lt; '\ 0' ,它在不到一秒的时间内执行。