0
votes

I'm writing an app that will be uploading files to FTP server. To connect with FTP server I'm using FTPClient from org.apache.commons.net.ftp. When I run my code locally everything is ok, but problem occurs when trying to login to ftp from Heroku dyno. There are no any errors in server logs, only get and post informations. Following log is displayed by FTPClient:

app[web.1]: 220 FTP server ready
app[web.1]: PASS XXX
app[web.1]: USER XXX
app[web.1]: 331 Password required for XXX
app[web.1]: 530 Login incorrect.
app[web.1]: TYPE I
app[web.1]: 221 Goodbye.
app[web.1]: QUIT
app[web.1]: 530 Please login with USER and PASS
app[web.1]: 200 Type set to I
app[web.1]: PORT 172,17,212,146,145,63

Password and login are ok because it works locally. I thought that it may be encoding on heroku but i changed it to utf-8 but error is still that same. I'm using following code to connect with FTP

private FTPClient ftp;

public void connect(String host, String username, String password) throws IOException {
    ftp = new FTPClient();
    ftp.enterLocalPassiveMode();
    ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
    ftp.connect(host);
    ftp.login(username,password);
    ftp.setFileType(FTP.BINARY_FILE_TYPE);
}

Application is deployed on jetty server.

EDIT
I don't mentioned it before, I'm login to that same FTP server in both cases (local and on heroku). Password and login are send in correct order. I tried also to do it manually it means that i called methods username and password instead of login so i'm sure that orded is correct

1

1 Answers

0
votes

It appears that you are sending PASS before sending USER, and not the other way around as I would expect. This probably works for your local FTP server, but does not work on whatever FTP server your dyno is trying to connect to.