I have Node.js app, I'm trying to connect to an FTP server and list the folders/files that are in the FTP server folder.
The server is configured with: TLS/SSL Implicit Encryption
Here's my code:
async function listFilesInFtpFolder() {
const client = new ftp.Client()
client.ftp.verbose = true;
try {
await client.access({
host: ftpConfig.host,
user: ftpConfig.user,
password: ftpConfig.password,
port: ftpConfig.port,
secure: false
});
// ********************** NOTE **********************
// The execution never reaches here, it gets stuck in the
// ... previous statement until it times out
// ********************** NOTE **********************
console.log('connected');
console.log(await client.list())
}
catch(err) {
console.log(err)
}
client.close()
}
Getting this error:
Listening on port 3001
Connected to 155.66.22.88:6610
Error: Timeout (control socket)
at Socket.<anonymous> (C:\Dev\my-app\node_modules\basic-ftp\dist\FtpContext.js:296:58)
at Object.onceWrapper (events.js:298:28)
at Socket.emit (events.js:209:13)
at Socket._onTimeout (net.js:468:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
The execution never reaches these lines:
console.log('connected');
console.log(await client.list())
It gets stuck waiting for the access method until it times out For some weird reason the access method reports "Connected"
Note if I use a program like WinSCP (https://winscp.net/) to connect to this FTP server I'm able to connect and see the folders. But for some weird reason I cannot connect from nodejs. I tried many FTP libraries too.