0

I'm creating service on node.js and have a small problem with module node-ssh

ssh.connect({
host: server.ssh.host,
port: server.ssh.port || 22,
username: server.ssh.username,
password: server.ssh.password})
.catch((e) => {
      log(
        `Problem while trying connect to ssh server ${server.name} ${server.ssh.host} ${e}`
      );
    });

How to catch exception from client.js which is in node_modules?

/server/node_modules/ssh2/lib/client.js:1014
      const err = new Error('Timed out while waiting for handshake');
                  ^
Error: Timed out while waiting for handshake
at Timeout._onTimeout (/server/node_modules/ssh2/lib/client.js:1014:23)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7) {
level: 'client-timeout'
}

The error destroying whole service, it should be catched by the catch after connect I think, but sth get wrong.

Dafik
  • 101
  • 1
  • 1
  • 8

0 Answers0