realtymaps / promise-ftp

a promise-based ftp client for node.js
MIT License
81 stars 27 forks source link

Problem to list files when deploy #50

Closed LuisFelipe1406 closed 8 months ago

LuisFelipe1406 commented 9 months ago

Hey guys, really good work with this lib, it was being very useful to my project. I´m facing a problem for weeks and have no solution yet. I would like to ask anyone who can help me with this.

I have a FTP server with so many files in there, my goal is to build a interface for manipulate these files. I want to search, download and delete specific files. I´m using Node to create a Express application that get the files on FTP and send them to my frontend builded with Vue.

My local tests are working very well, as I want. However, when I deploy my server (already tested different plataforms) I cannot reach any file. I can connect with the FTP and the server return a positive response, but when I use Get method on the source directory all I get is an empty array. There isn´t any error or exception, it just returns nothing.

I´ll let here the config of my connection and the method I´m using. Any doubts, don´t hesitate to talk to me, I´ll be so grateful with your help.

const info = {
    host: process.env.FTP_HOST,
    user: process.env.FTP_USER,
    password: process.env.FTP_PASSWORD,
    connTimeout: 21000,
    pasvTimeout: 21000,
    pasv: true
}
export async function listRaw(): Promise<Conteudo[]> {
    const ftp = new PromiseFtp();

    return new Promise((resolve, reject) => {
        ftp.connect(info)
            .then(function(serverMsg) {
                console.log(serverMsg);

                return ftp.list("/");
            })
            .then(function(list: Conteudo[]) {
                ftp.end();

                if (!list) {
                    return;
                }

                resolve(list);
            });
    });
}
LuisFelipe1406 commented 8 months ago

I recently discover the problem is in our FTP server. It only accepts connection from regional IP´s, when I deploy my app, the virtual machine is on other country and the FTP block it.

I´ll let it here, in case of helping someone else.