question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timed out while waiting for handshake

See original GitHub issue

I have set redyTimeout to 99999, but it still connects time out. I use sftp on the command line, it works to connect my host. Please some suggestions on how can I process it. Thanks.

  • nodejs version: v12.16.0
  • ssh2-sftp-client version: 6.13.4
  • OS: macOS Mojave 10.14.6

this is code

const SftpClient = require("ssh2-sftp-client");

const sftp = new SftpClient();
sftp.connect({
    host: config.sftpHost,
    port: config.sftpPort,
    username: config.sftpID,
    password: config.sftpPW,
    protocol: "sftp",
    readyTimeout: 99999,
    debug: console.log,
    algorithms: {
        kex: [
            "diffie-hellman-group1-sha1",
            "ecdh-sha2-nistp256",
            "ecdh-sha2-nistp384",
            "ecdh-sha2-nistp521",
            "diffie-hellman-group-exchange-sha256",
            "diffie-hellman-group14-sha1"
        ],
        cipher: [
            "3des-cbc",
            "aes128-ctr",
            "aes192-ctr",
            "aes256-ctr",
            "aes128-gcm",
            "aes128-gcm@openssh.com",
            "aes256-gcm",
            "aes256-gcm@openssh.com",
            "aes256-cbc"
        ],
        serverHostKey: [
            "ssh-rsa",
            "ssh-dss",
            "ecdsa-sha2-nistp256",
            "ecdsa-sha2-nistp384",
            "ecdsa-sha2-nistp521"
        ],
        hmac: ["hmac-sha2-256", "hmac-sha2-512", "hmac-sha1"]
    }
})
    .then(() => {
        console.log("connect SFTP!!");
        return sftp.list("/");
       // return sftp.get(remotePath, dst))
    })
    .then(() => {
        console.log("connect SFTP!!");
        sftp.end();
    })
    .catch(err => {
        console.error(err.message);
    });

this is debug log

Protocol.js:125
Handshake: S->C compression: none
Protocol.js:125
Outbound: Sending KEXDH_INIT
Protocol.js:125
Received DH Reply
Protocol.js:125
Host accepted by default (no verification)
Protocol.js:125
Host accepted (verified)
Protocol.js:125
CLIENT[sftp]: getConnection: Handling error: Timed out while waiting for handshake
index.js:80
CLIENT[sftp]: getConnection: handled error with reject
index.js:80
CLIENT[sftp]: Global: Ignoring handled error
index.js:80
CLIENT[sftp]: getConnection: finally clause fired
index.js:80
Socket closed
client.js:753
CLIENT[sftp]: getConnection: handling unexpected close event
index.js:80
CLIENT[sftp]: getConnection: handling close event with reject
index.js:80
CLIENT[sftp]: Global: Ignoring handled close event
index.js:80
CLIENT[sftp]: Removing listener from ready event
index.js:80
CLIENT[sftp]: getConnection: Removing temp event listeners
index.js:80
CLIENT[sftp]: getConnection retry catch
index.js:80
CLIENT[sftp]: connect: Error getConnection: Timed out while waiting for handshake
index.js:80```

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:34 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
theophilusxcommented, Aug 18, 2021

About to push version v7.0.2, which is based on ssh2 1.3.0, that includes the patch to fix the timeout issue.

1reaction
theophilusxcommented, Nov 17, 2022

Sorry, I don’t use docker, so cannot help.

I do know that without exception, every report I have had which involves docker and connection issues has been due to a configuration issue with docker. It is usually related to the network stack and firewalls or MTU settings.

Are you able to connect from within the docker container using openSSH CLI? Have you done basic network diagnosis like pings, traceroutes DNS lookups, disabling firewalls etc?a Do the logs on the remote sftp server provide any clues (if you have access)? Have you tried connecting from the docker container to a different sftp server?

You probably need to seek assistance on a docker specific forum.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ssh2 timed out while waiting for handshake - node.js
I am trying to use node.js to issue command line in my Linux servers via ssh. I found this https://github.com/mscdex/ssh2 and tried to...
Read more >
DigitalOcean timeout while waiting for handshake - Bobcares
How to resolve DigitalOcean timeout while waiting for handshake? · Firstly, check for ssh misconfigurations. · Check if there is any firewall rule ......
Read more >
Copy files over SSH, Error: Timed out while waiting for ...
Please create a new service connection of the SSH and use the new service connection to retry it. And here are some possible...
Read more >
Timed out while waiting for handshake - DigitalOcean
Digitalocean Droplet Droplet Web Console Error: Timed out while waiting for handshake · Posted on August 12, 2021 · DigitalOcean Droplets.
Read more >
Node SSH ERROR: Timed out - Questions - n8n community
Error : Timed out while waiting for handshake at Timeout._onTimeout (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/client.js:1014:23) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found