Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in Java FTP by (240 points)
Hello All,

I was hoping to get some help here. I have an application (written in Java and running on a Windows box) that connects to a Linux machine and pulls data.

Recently, I was requested to limit my port range so I added the following call to my code

setActivePortRange(12000,12100);

Now when I connect, I get the following error:

Address already in use: JVM_Bind

What does this mean? Is this something that is network related?

Thanks,
Jer

2 Answers

0 votes
by (162k points)
It could be that another application on your machine is using one of these ports.

Try netstat -a to have a look.

Also post a relevant chunk of the log file set to DEBUG.
0 votes
by (240 points)
Bruce,

I created a hack small program and ran 2 copies of it at the same time. I was able to generate the same error that I got from my original program.

Here is my code: (my 2nd copy changed its name only)

FTPClient ftp = new FTPClient("fdspacq2.dev.us.factiva.net");

ftp.debugResponses(true);

ftp.login("dist", "password");
String ftpServer = ftp.system();
log.logEvent("Logged onto server:" + ftpServer, false);
      
ftp.setType(FTPTransferType.ASCII);
ftp.setConnectMode(FTPConnectMode.ACTIVE);
ftp.setActivePortRange(12000,12100);

// Loop forever
for (; ; )
{
     log.logEvent("Checking: " + dirs[i], false);
     ftp.chdir(dirs[i]);
     
     String[] listings = ftp.dir(dirs[i], false);
     if (listings.length > 0)
        log.logEvent("First file is [" + listings[0] + "]", false);
     if (i == 4)
     {
        i = 0;
        log.logEvent("   ", false);
     }
     else
        i++;
}


When I start my second copy, I get an exception that looks like this:

C:\Java\Utilities\FTP>java com.factiva.fsp2.datacapture.FTPTest 1>screen.out
Failed to calculate version: For input string: "@major_ver@"
Exception in thread "main" java.net.BindException: Address already in use: JVM_B
ind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(Unknown Source)
        at java.net.ServerSocket.bind(Unknown Source)
        at java.net.ServerSocket.<init>(Unknown Source)
        at java.net.ServerSocket.<init>(Unknown Source)
        at com.factiva.fsp2.datacapture.FTPControlSocket.newActiveDataSocket(FTPControlSocket.java:632)
        at com.factiva.fsp2.datacapture.FTPControlSocket.createDataSocketActive(FTPControlSocket.java:416)
        at com.factiva.fsp2.datacapture.FTPControlSocket.createDataSocket(FTPControlSocket.java:399)
        at com.factiva.fsp2.datacapture.FTPClient.dir(FTPClient.java:2039)
        at com.factiva.fsp2.datacapture.FTPTest.ftpstart(FTPTest.java:106)
        at com.factiva.fsp2.datacapture.FTPTest.main(FTPTest.java:37 


My debug doesn't show alot. Here is the first program:

DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.901 : ---> USER dist
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.901 : 331 Please specify the password.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.901 : ---> PASS ********
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.901 : 230 Login successful.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.901 : ---> SYST
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : 215 UNIX Type: L8
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : ---> TYPE A
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : 200 Switching to ASCII mode.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : ---> CWD /AB/
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : 250 Directory successfully changed.
reply: 250
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.917 : ---> PORT 172,25,8,10,46,224
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : 200 PORT command successful. Consider using PASV.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : ---> NLST /AB/
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : 150 Here comes the directory listing.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : 226 Directory send OK.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : ---> CWD /STOCK/
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:32.933 : 250 Directory successfully changed.
reply: 250


and here is the 2nd

about to connect
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : ---> USER dist
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : 331 Please specify the password.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : ---> PASS ********
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : 230 Login successful.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : ---> SYST
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : 215 UNIX Type: L8
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : ---> TYPE A
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : 200 Switching to ASCII mode.
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : ---> CWD /AB/
DEBUG [com.factiva.fsp2.datacapture.FTPControlSocket] 7 Feb 2008 11:18:43.855 : 250 Directory successfully changed.
reply: 250



Interesting enough if I change the active port location in the 2nd program to a different set of ports they both work without issue.

Thoughts?

Thanks in advance.
Jer

Categories

...