It would appear that starting a listener twice produces this problem. If you
run the following, then the problem occurs:
* BasicConfigurator.configure();
DefaultFtpServer server = (DefaultFtpServer) new
FtpServerFactory().createServer();
server.getListeners().clear();
ListenerFactory listenFactory = new ListenerFactory();
listenFactory.setPort(21);
listenFactory.setServerAddress("127.0.0.1");
DataConnectionConfigurationFactory dataConnFactory = new
DataConnectionConfigurationFactory();
dataConnFactory.setIdleTime(0);
listenFactory.setDataConnectionConfiguration(dataConnFactory.createDataConnectionConfiguration());
Listener result = listenFactory.createListener();
server.getListeners().clear();
server.getListeners().put("127.0.0.1", result);
server.start();
for (Listener listener : server.getListeners().values())
{
listener.start(server.getServerContext());
}
for (Listener listener : server.getListeners().values())
{
listener.suspend();
}*
BUT..... If you remove the following:
* for (Listener listener : server.getListeners().values())
{
listener.start(server.getServerContext());
}
*The listener suspends and an FTP connection cannot be made.
On Tue, Sep 14, 2010 at 1:44 PM, Niklas Gustavsson <[email protected]>wrote:
> On Tue, Sep 14, 2010 at 2:36 PM, Aidan Diffey <[email protected]>
> wrote:
> > Is there any chance of getting your test code where this behavior didn't
> > happen?
>
> I simply used the following patch:
> Index: src/main/java/org/apache/ftpserver/main/CommandLine.java
> ===================================================================
> --- src/main/java/org/apache/ftpserver/main/CommandLine.java (revision
> 996857)
> +++ src/main/java/org/apache/ftpserver/main/CommandLine.java (working
> copy)
> @@ -21,6 +21,7 @@
>
> import org.apache.ftpserver.FtpServer;
> import org.apache.ftpserver.FtpServerFactory;
> +import org.apache.ftpserver.impl.DefaultFtpServer;
> import
> org.springframework.context.support.FileSystemXmlApplicationContext;
>
> /**
> @@ -62,6 +63,9 @@
> server.start();
> System.out.println("FtpServer started");
>
> + ((DefaultFtpServer)server).getListener("listener0").suspend();
> + System.out.println("suspended");
> +
> // add shutdown hook if possible
> cli.addShutdownHook(server);
> } catch (Exception ex) {
>
> This was on trunk. Also, I'm on OS X.
>
> Without the patch:
> > netstat -an | grep 2222
> tcp46 0 0 *.22222 *.* LISTEN
> >
>
> With the patch:
> > netstat -an | grep 2222
> >
>
> /niklas
>