mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aidan Diffey <aidan.dif...@gmail.com>
Subject Re: Stopping / Starting listeners
Date Tue, 14 Sep 2010 13:07:39 GMT
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 <niklas@protocol7.com>wrote:

> On Tue, Sep 14, 2010 at 2:36 PM, Aidan Diffey <aidan.diffey@gmail.com>
> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message