mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frank buloup <franck.bul...@univmed.fr>
Subject Connection closed without indication
Date Tue, 29 Mar 2011 13:56:31 GMT
Hello,

I'm trying to use FtpServer in my code and I have what I think to be a 
thread issue, but not sure.
That's why I ask for help, please, because I've not been able to find my 
error !

When I run a "classic" client and server, everything work fine. The user 
properties file is found,
with only one user called "paul", and server is correctly started with 
this message :

Nb users :1
Users name :paul
298 [main] INFO org.apache.ftpserver.impl.DefaultFtpServer - FTP server 
started

I suppose [main] means that server is running in main thread.
You can have a look at "classic" server code below.

When a connection is initiated from the client (see "classic" client 
code below), here are messages
coming from server (as you can see everything is working fine) :

302734 [NioProcessor-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - CREATED
302740 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - OPENED
onConnect
302753 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 220 Service 
ready for new user.
302756 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - RECEIVED: USER paul
302759 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 331 User name 
okay, need password for paul.
302760 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - RECEIVED: PASS *****
onLogin
302837 [pool-3-thread-1] INFO org.apache.ftpserver.command.impl.PASS - 
Login success - paul
302837 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - RECEIVED: SYST
302838 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 230 User 
logged in, proceed.
302838 [pool-3-thread-2] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 215 UNIX 
Type: Apache FtpServer
302880 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - RECEIVED: PORT 
127,0,0,1,197,145
302884 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 200 Command 
PORT okay.
302885 [pool-3-thread-2] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - RECEIVED: LIST
302939 [pool-3-thread-2] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 150 File 
status okay; about to open data connection.
302950 [pool-3-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - SENT: 226 Closing 
data connection.
302987 [pool-3-thread-2] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - CLOSED

Now if I use the same kind of code (of course you have to trust me) 
within a GUI interface (SWT-JFace), here what I get when server is started :

Nb users :1
Users name :paul
1741735 [Thread-0] INFO org.apache.ftpserver.impl.DefaultFtpServer - FTP 
server started

What I can notice is that it seems we are not in main thread ???

And when a client tries to connect, here are messages coming from server :

1831252 [NioProcessor-3] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - CREATED
1831257 [pool-6-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - OPENED
1831261 [pool-6-thread-1] INFO 
org.apache.ftpserver.listener.nio.FtpLoggingFilter - CLOSED

and messages coming from client :

org.apache.commons.net.ftp.FTPConnectionClosedException: Connection 
closed without indication.
     at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:298)
     at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:365)
     at 
org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:630)
     at org.apache.commons.net.SocketClient.connect(SocketClient.java:164)
     at org.apache.commons.net.SocketClient.connect(SocketClient.java:184)
     at snippet.FTPClientTest.<init>(FTPClientTest.java:14)
     at snippet.FTPClientTest.main(FTPClientTest.java:30)


Any help would be nice,
thanks a lot,
frank

------------------------------------------------------------------------------------

*_Classic SERVER code :_*
public class FTPServerTest extends DefaultFtplet {
     public FTPServerTest() {
         try {
             FtpServerFactory serverFactory = new FtpServerFactory();
             PropertiesUserManagerFactory userManagerFactory = new 
PropertiesUserManagerFactory();
             userManagerFactory.setFile(new File("./users.properties"));
             userManagerFactory
                     .setPasswordEncryptor(new SaltedPasswordEncryptor());
             UserManager userManager = 
userManagerFactory.createUserManager();
             String[] users = userManager.getAllUserNames();
             System.out.println("Nb users :" + users.length);
             if (users.length > 0)
                 System.out.println("Users name :" + users[0]);
             serverFactory.setUserManager(userManager);
             ListenerFactory factory = new ListenerFactory();
             factory.setPort(2221);
             serverFactory.addListener("default", factory.createListener());
             HashMap<String, Ftplet> ftplets = new HashMap<String, 
Ftplet>(0);
             ftplets.put("DEFAULT", this);
             serverFactory.setFtplets(ftplets);
             FtpServer server = serverFactory.createServer();
             server.start();
         } catch (FtpException e) {
             e.printStackTrace();
         }
     }

     public static void main(String[] args) {
         new FTPServerTest();
     }

     @Override
     public FtpletResult onConnect(FtpSession session) throws FtpException,
             IOException {
         System.out.println("onConnect");
         return FtpletResult.DEFAULT;
     }

     @Override
     public FtpletResult onLogin(FtpSession session, FtpRequest request)
             throws FtpException, IOException {
         System.out.println("onLogin");
         return FtpletResult.DEFAULT;
     }
}

*_Classic CLIENT code :_*
     public FTPClientTest() {
         try {
             FTPClient ftpClient = new FTPClient();
             ftpClient.connect("127.0.0.1", 2221);
             ftpClient.login("paul", "paul");
             FTPFile[] files = ftpClient.listFiles();
             for (int i = 0; i < files.length; i++) {
                 FTPFile ftpFile = files[i];
                 System.out.println(ftpFile.getName());
             }
             ftpClient.disconnect();
         } catch (SocketException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
         }
     }

     public static void main(String[] args) {
         new FTPClientTest();
     }


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