Connection cannot be established to FTP server using nodejs

Viewed 1320

I´m currently trying to connect to a FTP server using the nodeJS lib basic-ftp. It seems that a connection was established, but I cannot perform a single operation or even output a log statement after trying to access the server. The code then runs into an timeout.. I can ping the server from my local environment using Windows CMD ping command..

const ftp = require("basic-ftp")

example()

async function example() {
    const client = new ftp.Client(timeout = 30000)
    client.ftp.verbose = true
    try {
        await client.access({
            host: "10.xxx.xx.xx",
            port: 2222,
            user: "xxx",
            pass: "xxxx",
            secure: true
        })
        console.log("CONNECTED");
        console.log(await client.ensureDir("/PATH/"));
        console.log(await client.list('/PATH/'));
      
    }
    catch (err) {
        console.log(err)
    }
    client.close()
}

Output:

Connected to 10.xxx.xx.xxx:2222 (No encryption)
< SSH-2.0-WS_FTP-SSH_8.5.0

Error: Timeout (control socket)
    at Socket.<anonymous> (C:\Users\xxx\dev\nodejs\ftpTest\node_modules\basic-ftp\dist\FtpContext.js:316:58)
    at Object.onceWrapper (events.js:299:28)
    at Socket.emit (events.js:210:5)
    at Socket._onTimeout (net.js:469:8)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

There is almost no output that helps me to identify the issue. I can establish a connection using WinSCP.

Does someone have an idea what could cause the problem and which steps are required to identify what could cause this issue?

Thanks a lot!

EDIT:

Could it be that there is some kind of key exchange missing? I had to click yes when using WinSCP!

0 Answers
Related