Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.3k views
in Java FTP by (200 points)
Hello!

I really hope you can help me with my problem, because I have no idea what is wrong... In my program I'm trying to connect to a server with a ftp connection. There i first want to check if some folders already exist and if not, I want to create them. I can connect to the server with no problems, but when I want to list the root directory, I get an error: 500 Invalid PORT Command. I'm connecting to port 22, and obviously that is OK because the connecting part is OK. What could be the problem? Here the log:

INFO [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.091 : Creating FTP client
DEBUG [FTPClient] 16 Nov 2012 22:54:20.152 : Class: com.enterprisedt.net.ftp.FTPClient
Location: file:/C:/Viki/Sluzba/Vnos%20Faktur%20App/resources/edtftpj.jar
Version: 2.3.0
Build timestamp: 26-Aug-2011 13:52:07 EST
Java version: 1.7.0_03
CLASSPATH: C:\Program Files\NetBeans 7.1.1\java\modules\ext\beansbinding-1.2.1.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\jcalendar-1.4.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\mysql-connector-java-5.1.17-bin.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\edtftpj.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\log4j-1.2.16.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\sqljdbc4.jar;C:\Viki\Sluzba\Vnos Faktur App\ICEpdf-4.3.2-bin\ICEpdf-4.3.2-bin\icepdf\lib\icepdf-core.jar;C:\Viki\Sluzba\Vnos Faktur App\ICEpdf-4.3.2-bin\ICEpdf-4.3.2-bin\icepdf\lib\icepdf-viewer.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0-javadoc.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0-sources.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0-javadoc.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0-sources.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0.jar;C:\Users\Viki\NetBeansProjects\Vnos_Faktur_glavni\build\classes
OS name: Windows 7
OS arch: x86
OS version: 6.1

INFO [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.157 : Setting remote host
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.157 : Connecting to server xx.xxx.xxx.xxx
DEBUG [FileTransferClient] 16 Nov 2012 22:54:20.158 : Configured client
DEBUG [FTPClient] 16 Nov 2012 22:54:20.158 : Connecting to /xx.xxx.xxx.xxx:22
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.246 : 220 Microsoft FTP Service
DEBUG [FileTransferClient] 16 Nov 2012 22:54:20.249 : Client connected
DEBUG [FileTransferClient] 16 Nov 2012 22:54:20.249 : Logging in
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.249 : ---> USER FileSistemAdmin
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.296 : 331 Password required for FileSistemAdmin.
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.297 : ---> PASS ********
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.341 : 230 User FileSistemAdmin logged in.
DEBUG [FileTransferClient] 16 Nov 2012 22:54:20.342 : Logged in
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.342 : ---> TYPE I
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.383 : 200 Type set to I.
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.383 : Connected and logged in to server xx.xxx.xxx.xxx with port: 22
Connected to FTP server.
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.384 : Getting current directory listing
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.394 : ---> SYST
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.474 : 215 Windows_NT
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.484 : ---> PWD
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.551 : 257 "/" is current directory.
DEBUG [FTPClient] 16 Nov 2012 22:54:20.552 : setupDirDetails(.) returning: /
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.554 : ListenOnAllInterfaces=true
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.557 : ---> PORT 192,168,0,64,19,17
DEBUG [FTPControlSocket] 16 Nov 2012 22:54:20.647 : 500 Invalid PORT Command.
INFO [FTPControlSocket] 16 Nov 2012 22:54:20.647 : Expected reply codes = [200,250]
DEBUG [virtcomFakture.Main.VirtcomGUIOsnova] 16 Nov 2012 22:54:20.648 : null : Invalid PORT Command.
com.enterprisedt.net.ftp.FTPException: 500 Invalid PORT Command.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1223)
at com.enterprisedt.net.ftp.FTPControlSocket.setDataPort(FTPControlSocket.java:815)
at com.enterprisedt.net.ftp.FTPControlSocket.sendPORTCommand(FTPControlSocket.java:669)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketActive(FTPControlSocket.java:616)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:583)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2648)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3664)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3756)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:3583)
at com.enterprisedt.net.ftp.FileTransferClient.directoryList(FileTransferClient.java:647)
at virtcomFakture.Main.VirtcomGUIOsnova.manageFolders(VirtcomGUIOsnova.java:6414)
at virtcomFakture.Main.VirtcomGUIOsnova.access$22600(VirtcomGUIOsnova.java:54)
at virtcomFakture.Main.VirtcomGUIOsnova$226.run(VirtcomGUIOsnova.java:6120)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


I really have no idea why this is happening... If it helps - I am now trying to connect to a remote server (and I keep getting this error), but before (in first fase of development) I was connecting to a "server" within my home network with the same settings and it worked fine... The only thing I now changed are host and port....

I'd really appreciate your help.

Thanks :)

5 Answers

0 votes
by (162k points)
You most likely need to call setActiveIPAddress("your ipaddress")
0 votes
by (200 points)
OK, so I tried that, using my localhost IP and my "external"/router IP, but both times got the same error. I can connect to the server, but cannot read directory listings. This is how the log looks like:

INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.082 : Setting active IP address(MyIP)
Active ip: yy.yyy.yyy.y
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.120 : Creating FTP client
DEBUG [FTPClient] 8 Dec 2012 12:43:02.138 : Class: com.enterprisedt.net.ftp.FTPClient
Location: file:/C:/Viki/Sluzba/Vnos%20Faktur%20App/resources/edtftpj.jar
Version: 2.3.0
Build timestamp: 26-Aug-2011 13:52:07 EST
Java version: 1.7.0_03
CLASSPATH: C:\Program Files\NetBeans 7.1.1\java\modules\ext\beansbinding-1.2.1.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\jcalendar-1.4.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\mysql-connector-java-5.1.17-bin.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\edtftpj.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\log4j-1.2.16.jar;C:\Viki\Sluzba\Vnos Faktur App\resources\sqljdbc4.jar;C:\Viki\Sluzba\Vnos Faktur App\ICEpdf-4.3.2-bin\ICEpdf-4.3.2-bin\icepdf\lib\icepdf-core.jar;C:\Viki\Sluzba\Vnos Faktur App\ICEpdf-4.3.2-bin\ICEpdf-4.3.2-bin\icepdf\lib\icepdf-viewer.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0-javadoc.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0-sources.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itext-xtra-5.3.0.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0-javadoc.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0-sources.jar;C:\Viki\Sluzba\Vnos Faktur App\itext-5.3.0\itextpdf-5.3.0.jar;C:\Users\Viki\NetBeansProjects\Vnos_Faktur_glavni\build\classes
OS name: Windows 7
OS arch: x86
OS version: 6.1

INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.151 : Setting remote host
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.152 : Connecting to server xx.xxx.xxx.xxx
DEBUG [FileTransferClient] 8 Dec 2012 12:43:02.152 : Configured client
DEBUG [FTPClient] 8 Dec 2012 12:43:02.152 : Connecting to / xx.xxx.xxx.xxx:22
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.244 : 220 Microsoft FTP Service
DEBUG [FileTransferClient] 8 Dec 2012 12:43:02.246 : Client connected
DEBUG [FileTransferClient] 8 Dec 2012 12:43:02.246 : Logging in
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.247 : ---> USER FileSistemAdmin
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.285 : 331 Password required for FileSistemAdmin.
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.285 : ---> PASS ********
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.323 : 230 User FileSistemAdmin logged in.
DEBUG [FileTransferClient] 8 Dec 2012 12:43:02.323 : Logged in
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.323 : ---> TYPE I
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.372 : 200 Type set to I.
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.372 : Connected and logged in to server xx.xxx.xxx.xxx with port: 22
Connected to FTP server.
INFO [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.372 : Getting current directory listing
Active ip: yy.yyy.yyy.y
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.382 : ---> SYST
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.420 : 215 Windows_NT
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.428 : ---> PWD
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.476 : 257 "/" is current directory.
DEBUG [FTPClient] 8 Dec 2012 12:43:02.476 : setupDirDetails() returning: /
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.477 : ListenOnAllInterfaces=true
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.479 : ---> PORT 192,168,0,64,11,26
DEBUG [FTPControlSocket] 8 Dec 2012 12:43:02.517 : 500 Invalid PORT Command.
INFO [FTPControlSocket] 8 Dec 2012 12:43:02.517 : Expected reply codes = [200,250]
DEBUG [virtcomFakture.Main.VirtcomGUIOsnova] 8 Dec 2012 12:43:02.518 : null : Invalid PORT Command.
com.enterprisedt.net.ftp.FTPException: 500 Invalid PORT Command.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1223)
at com.enterprisedt.net.ftp.FTPControlSocket.setDataPort(FTPControlSocket.java:815)
at com.enterprisedt.net.ftp.FTPControlSocket.sendPORTCommand(FTPControlSocket.java:669)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketActive(FTPControlSocket.java:616)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:583)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2648)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3664)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3756)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:3583)
at com.enterprisedt.net.ftp.FileTransferClient.directoryList(FileTransferClient.java:647)
at com.enterprisedt.net.ftp.FileTransferClient.directoryList(FileTransferClient.java:633)
at virtcomFakture.Main.VirtcomGUIOsnova.manageFolders(VirtcomGUIOsnova.java:6423)
at virtcomFakture.Main.VirtcomGUIOsnova.access$22600(VirtcomGUIOsnova.java:52)
at virtcomFakture.Main.VirtcomGUIOsnova$226.run(VirtcomGUIOsnova.java:6118)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


com.enterprisedt.net.ftp.FTPException: 500 Invalid PORT Command.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1223)
at com.enterprisedt.net.ftp.FTPControlSocket.setDataPort(FTPControlSocket.java:815)
at com.enterprisedt.net.ftp.FTPControlSocket.sendPORTCommand(FTPControlSocket.java:669)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketActive(FTPControlSocket.java:616)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:583)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2648)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3664)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3756)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:3583)
at com.enterprisedt.net.ftp.FileTransferClient.directoryList(FileTransferClient.java:647)
at com.enterprisedt.net.ftp.FileTransferClient.directoryList(FileTransferClient.java:633)
at virtcomFakture.Main.VirtcomGUIOsnova.manageFolders(VirtcomGUIOsnova.java:6423)
at virtcomFakture.Main.VirtcomGUIOsnova.access$22600(VirtcomGUIOsnova.java:52)
at virtcomFakture.Main.VirtcomGUIOsnova$226.run(VirtcomGUIOsnova.java:6118)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.a
0 votes
by (162k points)
You need to set the active IP address to an IP reachable by the server. It has to connect back to your client - 192.168 address is probably not going to work unless the server is on the same local network.
0 votes
by (200 points)
I understand that 192.168 IP would not work, so I tried setting my public (external) WAN-IP address as the active IP. But the error I get is the same. What am I doing wrong? As far as I know, a router has two IP's - LAN IP, for home network (192.168) and another one, which is for the external Internet connection. So if I understand everything right, this should be set as the active IP. Am I missing something?
0 votes
by (162k points)
Your firewall may be preventing the connection. You could try passive mode instead of active mode.

Categories

...