1

The function of SFTP is working locally and it has the correct configuration. The problem is with the logs of Lambda that complains about the configuration I believe by giving me an Error: Timed out while waiting for a handshake.

const config = {
    host: 'ftp.xxxx.at',
    port: '22',
    username: 'SFTP_xxx',
    password: 'xxx9fBcS45',
    MD5_Fingerprint: 'xxx:8f:5b:1a',
    protocol: "sftp",
    algorithms: {
        serverHostKey: ['ssh-rsa', 'ssh-dss']
      }
};


// get file
// get sftp file
// here ....
const get = () => {
    sftp.connect(config).then(() => {
        return sftp.get('./EMRFID_201811210903.csv', null, 'utf8', null);
    }).then((stream) => {
        let body = stream.on('data', (chunk) => {
            body += chunk;
        })
        stream.on('end', () => {

            uploadRFIDsToS3(body)
            // close connection
            sftp.end()
        });
    }).catch((err) => {
        console.log('catch err:', err)
    })
};

-

vpc:
  securityGroupIds:
  - sg-01c29be1d8fbxx59 

  subnetdIds:
  - subnet-007a88d9xxea434d

-

2019-02-18T13:53:51.121Z    e688c7bd-24fc-45a1-a565-f2a4c313f846    catch err: { Error: Timed out while waiting for handshake
at Timeout._onTimeout (/var/task/node_modules/ssh2-sftp-client/node_modules/ssh2/lib/client.js:695:19)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5) level: 'client-timeout' }

I added VPC and Security Group in AWS and I still get the same error. I ran out of ideas of how to fix it.

4

2 回答 2

0

我想通了。问题是 Lambda 实际上是在没有建立连接的情况下转到另一个函数。所以我所做的就是将等待添加到连接和其他不应相互干扰的功能中才能正常工作。

要了解有关 await 的更多信息,请访问此链接: https ://javascript.info/async-await

于 2019-03-11T11:18:53.587 回答
0

增加 lambda 函数的超时值。分配更多内存和超时的选项是 aws 中任何 lambda 函数的一些设置

于 2019-03-08T15:33:55.437 回答