Hi, folks I'm now using Ftp Server v1.0.4 in my Android app, generally speaking, it's working fine on Android 2.1 but I've found that some of my users may face a configuration related error, here's the stack trace:
Uncaught handler: thread main exiting due to uncaught exception java.lang.RuntimeException: Unable to start service xcxin.ftpserver.ftpserv...@440b1ae0 with Intent { cmp=xcxin.filexpert/xcxin.ftpserver.FtpService }: org.apache.ftpserver.FtpServerConfigurationException: Failed to bind to address 0.0.0.0/0.0.0.0:2211, check configuration at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2882) at android.app.ActivityThread.access$3500(ActivityThread.java:119) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4363) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at dalvik.system.NativeStart.main(Native Method) Caused by: org.apache.ftpserver.FtpServerConfigurationException: Failed to bind to address 0.0.0.0/0.0.0.0:2211, check configuration at org.apache.ftpserver.listener.nio.NioListener.start(NioListener.java:183) at org.apache.ftpserver.impl.DefaultFtpServer.start(DefaultFtpServer.java:80) at xcxin.ftpserver.FtpService.onStart(FtpService.java:86) at android.app.Service.onStartCommand(Service.java:306) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2873) ... 10 more Caused by: java.net.BindException: The address is already in use at org.apache.harmony.luni.platform.OSNetworkSystem.socketBindImpl(Native Method) at org.apache.harmony.luni.platform.OSNetworkSystem.bind(OSNetworkSystem.java:107) at org.apache.harmony.luni.net.PlainSocketImpl.bind(PlainSocketImpl.java:184) at java.net.ServerSocket.bind(ServerSocket.java:414) at org.apache.harmony.nio.internal.ServerSocketChannelImpl$ServerSocketAdapter.bind(ServerSocketChannelImpl.java:213) at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:248) at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:48) at org.apache.mina.core.polling.AbstractPollingIoAcceptor.registerHandles(AbstractPollingIoAcceptor.java:521) at org.apache.mina.core.polling.AbstractPollingIoAcceptor.access$200(AbstractPollingIoAcceptor.java:65) at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:405) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) Seems it's a binding error, but I don't know where I am wrong, below is code fragment I used in my app to configure the ftp server: String user = settings.getFtpUserName(); String pass = settings.getFtpPassword(); SimpleAuth myAuth = new SimpleAuth(); List<Authority> auth_list = new ArrayList<Authority>(); auth_list.add(myAuth); super.onStart(intent, startId); // Create User userFactory.setName(user); userFactory.setPassword(pass); userFactory.setHomeDirectory(root); userFactory.setEnabled(true); userFactory.setAuthorities(auth_list); // Setup the User Mgr userMgrFactory.setAdminName(user); serverFactory.setUserManager(userMgrFactory.createUserManager()); // Get User Mgr UserManager userMgr = serverFactory.getUserManager(); try { userMgr.save(userFactory.createUser()); } catch (FtpException e) { Log.v("FE", "Can not create user: " + e.toString()); this.stopSelf(); } // Set Port factory.setPort(settings.getFtpPort()); // Set Passive Ports dataConnFactory.setPassivePorts("4000-4199"); factory.setDataConnectionConfiguration(dataConnFactory.createDataConnectionConfiguration()); // Replace with default listener serverFactory.addListener("default", factory.createListener()); // Create Server ftpServer = serverFactory.createServer(); // Start Service try { ftpServer.start(); } catch (FtpException e) { Log.v("FE", "Can not start ftp server: " + e.toString()); this.stopSelf(); } Could someone please help me to see where I am wrong? Thank you! Alex