Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with passive mode. Failed to establish connection. Code 425. #158

Closed
stealson opened this issue Dec 16, 2015 · 2 comments
Closed

Comments

@stealson
Copy link

Hi,
I had some troubles with writing files in passive mode. The problem was that the server transmitted a wrong host IP to the client, but the correct ports for the passive mode. Because I had no troubles writing files with Transmit, I read it's connection protocol and found a correction of the transmitted host IP (where X.X.X.X is the wrong IP and Y.Y.Y.Y the correct one):

Cmd: PASV
227: Entering Passive Mode (X,X,X,X,195,84).
Fixing bogus PASV data address from X.X.X.X:50004 to Y.Y.Y.Y:50004.

So I came up with the idea to fix the IP address, too and added two lines to the jsftp's getPasvSocket method:

Ftp.prototype.getPasvSocket = function(callback) {
  var self = this;
  callback = once(callback || NOOP);

  var host = this.host;   // added
  this.execute('pasv', function(err, res) {
    if (err) return callback(err);

    getPasvPort(res.text, function(err, options) {
      if (err) return callback(err);

      options.host = host;  // added
      var socket = self._pasvSocket = Net.createConnection(options);
      socket.setTimeout(self.timeout || TIMEOUT);
      socket.once('connect', function() {
        self._pasvSocket = socket;
      });
      socket.once('close', function() {
        self._pasvSocket = undefined;
      });
      callback(null, socket);
    });
  });
};

Now it works just fine.
I know it is not the perfect way to to solve this problem, but I have no idea why the server sends the "wrong" IP address...

Somebody does?

@stealson
Copy link
Author

I found the problem in the vsftpd configurations: pasv_address was not set.
So, for me the ugly workaround from above is not necessary anymore...

@tagplus5
Copy link

I get same error when server set wrong host for on passive mode. I propose use hostPasv parameter (see my pull request).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants