Please prefix the subject line with the Commons Component in future (as above)

On 22 January 2017 at 09:12, Oliver Zemann <oliver.zem...@gmail.com> wrote:
> Hi, i would like to know how to handle FTP Servers that do not behave like
> they should (or behave different than most others).
> For example, currently i would like to connect to one of those servers which
> sends " MODE Z" directly after a login (USER) which is interpreted wrong by
> apache commons ftp, as its assumed that there should be \d\d\d \w* like "220
> all good my friend"
> But its simply: " MODE Z"
>
> Here is a log from filezilla which can handle this behaviour:
> 09:58:24    Trace:    CFtpControlSocket::SendNextCommand()
> 09:58:24    Befehl:    USER someUser
> 09:58:24    Trace:    CFtpControlSocket::OnReceive()
> 09:58:24    Antwort:    331  [33m ~wait~ user ok, password?
> 09:58:24    Trace:    CFtpControlSocket::SendNextCommand()
> 09:58:24    Befehl:    PASS *******
> 09:58:25    Trace:    CFtpControlSocket::OnReceive()
> 09:58:25    Antwort:    230  [32m.::WAIT::. welcome!.

The login has completed here

> 09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
> 09:58:25    Befehl:    SYST
> 09:58:25    Trace:    CFtpControlSocket::OnReceive()
> 09:58:25    Antwort:    215 Java (SE) Platform SE 6.0
> 09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
> 09:58:25    Befehl:    FEAT
> 09:58:25    Trace:    CFtpControlSocket::OnReceive()
> 09:58:25    Antwort:    211-Extension supported
> 09:58:25    Antwort:     MDTM
> 09:58:25    Antwort:     MDTM
> 09:58:25    Antwort:     MDTM YYYYMMDDHHMMSS[+-TZ];filename
> 09:58:25    Antwort:     SIZE
> 09:58:25    Antwort:     SITE PSWD;EXEC;SET;INDEX;ZONE;CHMOD;MSG
> 09:58:25    Antwort:     XCRC filename;start;end
> 09:58:25    Antwort:    211 End
> 09:58:25    Status:    Der Server unterstützt keine Nicht-ASCII-Zeichen.
> 09:58:25    Status:    Angemeldet
> 09:58:25    Antwort:     MODE Z
> 09:58:25    Trace:    Unexpected reply, no reply was pending. <----
> something like this in apache commons ftp???

Note that FileZilla detects this as an error, so clearly this is not
expected behaviour.

Commons NET only looks for  a reply when one is expected, so it cannot
detect this.
AFAICS changing this would require a major rewrite.
Since the server appears to be broken, it's not worth doing this.

> 09:58:25    Antwort:    211 End
> 09:58:25    Trace:    Unexpected reply, no reply was pending.
> 09:58:25    Status:    Empfange Verzeichnisinhalt...
> 09:58:25    Trace:    CFtpControlSocket::SendNextCommand()
> 09:58:25    Trace:    CFtpControlSocket::ChangeDirSend()
> 09:58:25    Befehl:    PWD
> 09:58:25    Trace:    CFtpControlSocket::OnReceive()
> 09:58:25    Antwort:    257 "/"  [34m<<<>>>OK<<<>>> Logged in ;).
>
> That "MODE Z" is leading to an exception when i use FTPClient::login()
> In __getReply(boolean reportReply)  i can see that its trying to convert the
> first 3 chars to a digit, which is of course impossible if its "Z MODE" and
> not a number.
>
> So i am wondering whats the best way to handle such servers? Or is this a
> bug in apache commons ftp? Do i have to implement all calls myself and dont
> rely on login() logout() etc. from apache commons to be able to handle such
> behaviours?

This seems to be a bug in the server.
It is not supposed to send unsolicited data on the command channel.

You might be able to subclass one of the FTP classes and over-ride one
of the methods so it ignores MODE Z if it's not expected.

> Some information: i dont have control over that server. I dont know what
> software the server is running.

Try contacting the server maintainers to raise the issue of the
server's bad behaviour

> Regards
> Oli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to