节点js:无法在MacOSx / Linux上的ssh2连接中捕获“错误”

this.connection = new Connection(); //ssh2 connection async.waterfall([function(callback) { // some initialization code to connect } }], function(err, opts) { if (err) { callback({ message: 'Error during connecting to the device...', detail: err }, false); } else { console.log('Connecting to ... ' + JSON.stringify(self.info)); self.connection.on('ready', function() { console.info('Connected... opening a shell...'); callback(null, true); }).on('error', function(err) { console.error('Error during connecting to the device: ' + err); callback({ message: 'Error during connecting to the device...', detail: err }, false); }).on('end', function() { console.info("Connection ended..."); }).on('close', function(hadError) { console.info("Connection closed..." + (hadError ? " with error" : "")); }).connect(opts); } }); 

参考上面的代码,我连接到一个使用ssh2连接的设备,一切工作正常..我正在获取控制台日志“就绪”,closures等,但无法获得控制台日志时,发生“错误”。

我可以在win7 32位上捕获“错误”事件,但不能在MacOSx(10.9.5)或Linux(Ubuntu 12)上捕获。 当我强行结束与设备的连接时(例如,从我的系统中拔出LAN电缆),触发“错误”事件。

这是一些限制在Mac / Linux的ssh2模块或是我在做错误的方式来捕捉错误。

任何指针都会很有帮助。

节点js版本v0.10.29 ssh2版本v0.4.8

在github https://github.com/mscdex/ssh2/issues/364引发了这个问题

解决scheme是使用一个keepaliveInterval,它的默认值是0.所以四处游戏,以保持我的应用程序的最佳价值,它的工作。