icetee / node-ftp

An FTP client module for node.js
MIT License
25 stars 16 forks source link

ABOR on multiple requests #12

Closed stanzahk closed 5 years ago

stanzahk commented 5 years ago

Hi,

i see a strange behavior when doing more that one concurrent request in passive mode. A tcpdump trace shows that the client sends ABOR, and the server replies with No transfer to ABOR.

The catched error is the following:

Error: Timed out while making data connection
    at Timeout.<anonymous> (node_modules/@icetee/ftp/lib/connection.js:968:12)
    at Timeout.<anonymous> (node_modules/async-listener/glue.js:188:31)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5) 

My code:

myproms = [];
creditnotes.forEach(function(creditnote, i) {
  let conn = new FtpClient(ftpParams);
  myproms.push(conn.connect().then(() => {
            logger.log('debug',
              '%s Uploading %s to %s in %s', uuid,
              filename, ftpParams.ftphost, destpath);
            return conn.put(xml, destpath + "/" + filename);
          }).then(() => {
            conn.end();
            return creditnote;
          }).catch((err) => {
            conn.destroy();
            throw err;
          }));
}
return Promise.all(myproms);
class FTPClient {
[...]
  connect() {
    var that = this;
    return new Promise(function(resolve, reject) {
      that.c.on('error', function(err) {
        return reject(err);
      });
      that.c.on('ready', function() {
        that.isready = true;
        return resolve(that.c);
      });
      that.c.connect({
        host: that.host,
        user: that.username,
        password: that.password,
        connTimeout: that.ftpConnTimeout,
        pasvTimeout: that.ftpPasvTimeout,
        debug: true,
        secure: that.secure
      });
    });
  }

  put(input, path) {
    var that = this;
    return new Promise(function(resolve, reject) {
      that.c.on('error', function(err) {
        return reject(err);
      });
      that.c.put(input, path, false, function(err) {
        if (err) {
          return reject(err);
        }
        return resolve();
      });
    });
  }

[...]
}

Am i doing something wrong?

stanzahk commented 5 years ago

Example capture:

220 Welcome to REDACTED
USER REDACTED
331 Please specify the password.
PASS REDACTED
230 Login successful.
FEAT
211-Features:
 EPRT
 EPSV
 MDTM
 PASV
 REST STREAM
 SIZE
 TVFS
 UTF8
211 End
OPTS UTF8 ON
200 Always in UTF8 mode.
TYPE I
200 Switching to Binary mode.
EPSV
229 Entering Extended Passive Mode (|||29666|).
ABOR
225 No transfer to ABOR.
stanzahk commented 5 years ago

It was a server side firewall configuration error.

marafat commented 4 years ago

@stanzahk - any idea what was the server side config that needed to be changed?