[ 
https://issues.apache.org/jira/browse/NET-568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14318937#comment-14318937
 ] 

Sebb commented on NET-568:
--------------------------

The FTPClientExample code includes an example of calling enterLocalPassiveMode 
[1]

This is done AFTER the connect [2] has occurred.

Also the Javadoc for enterLocalPassiveMode [3] says that connect resets the 
mode.

The code is working as documented.
 
[1] 
http://commons.apache.org/proper/commons-net/xref/examples/ftp/FTPClientExample.html#324
[2] 
http://commons.apache.org/proper/commons-net/xref/examples/ftp/FTPClientExample.html#263
[3] 
http://commons.apache.org/proper/commons-net/javadocs/api-3.3/org/apache/commons/net/ftp/FTPClient.html#enterLocalPassiveMode()

> Order of client configuration and connection is ambiguous
> ---------------------------------------------------------
>
>                 Key: NET-568
>                 URL: https://issues.apache.org/jira/browse/NET-568
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.3
>         Environment: linux, java 7
>            Reporter: Joseph Vychtrle
>
> Hey,
> according to the FTPClientExample client should be first configured and set 
> and connection made afterwards. But if I do this :
> {code:title=FTPClient.java}
>       FTPClient c = new FTPClient()
>       customConf(c)
>       val config = new FTPClientConfig("UNIX")
>       config.setUnparseableEntries(true)
>       c.configure(config)
>       c.enterLocalPassiveMode() // required, otherwise firewall issues happen
>       c.setDefaultTimeout(conf.ftpTimeout)
>       c.addProtocolCommandListener(new PrintCommandListener(new 
> PrintWriter(System.out), true))
>       c.connect(conf.ftpHost)
> {code}
> Then it basically ends up this way : 
> {code}
> 230 Anonymous access granted, restrictions apply
> PORT 192,168,1,100,177,38
> 500 Illegal PORT command
> {code}
> But if I call connect() before all the client setting including 
> enterLocalPassiveMode, then it works as expected. 
> {code}
> 230 Anonymous access granted, restrictions apply
> PASV
> 227 Entering Passive Mode (80,251,0,59,175,235).
> RETR welcome.msg
> 150 Opening ASCII mode data connection for welcome.msg (321 bytes)
> 226 Transfer complete
> PASV
> 227 Entering Passive Mode (80,251,0,59,167,178).
> RETR welcome.msg
> 150 Opening ASCII mode data connection for welcome.msg (321 bytes)
> 226 Transfer complete
> PASV
> 227 Entering Passive Mode (80,251,0,59,174,58).
> RETR welcome.msg
> 150 Opening ASCII mode data connection for welcome.msg (321 bytes)
> 226 Transfer complete
> {code}
> But in the FTPClientExample the connect() occurs at the end.
> It is thread-safe, running within a single thread... What is going on here?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to