Skip to content

TRY CATCH timeout #132

Closed
Closed

Description

@lucydjo

Hi,

How to catch ssh error connexion ?

(node:988) UnhandledPromiseRejectionWarning: Error: Timed out while waiting for handshake at Timeout._onTimeout (/home/dev/www_1/node_modules/ssh2/lib/client.js:687:19) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10) (node:988) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:988) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

also does not work

ssh.on('error', () => {  // Or close, end.
    console.log('ERRO');
})

Activity

  1. steelbrain commented on May 4, 2020

    @steelbrain
    Owner

    Thanks for the report @lucaspojo

    Is this error thrown during initial connection or during command execution? Any context here would help a lot.

  2. mctrivia commented on Sep 10, 2020

    @mctrivia

    I get this bug when I try to run on ubuntu 18.04 My windows test machine does not throw this error. Both machines are on the same network and trying to access the same machines.

  3. mctrivia commented on Sep 10, 2020

    @mctrivia

    as some quick testing. From ubuntu command line I can run

    ssh 10.0.1.50

    and get access to the requested device so there is definetly no network issue blocking. Problem is strictly with the node-ssh library not timing out when run from the ubuntu server but works on webstorm on the pc.

  4. heilmela commented on Nov 11, 2020

    @heilmela

    I can confirm this bug. In my case, it is thrown during initial connection (i assume ?), after i execute connect(...) on a new Client(). I'm unable to catch the error in the callback .on('error') {} nor in a try catch around the connection attempt.

  5. heilmela commented on Nov 11, 2020

    @heilmela

    Nevermind I'm able to catch the error. I was listening on client.exec().on('error', ..) not on the client directly with client.on('error', ...). Maybe this solves the problem for OP.

  6. steelbrain commented on Nov 16, 2026

    @steelbrain
    Owner

    Fix for this will be part of v14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions