Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.8k views
in Java FTP by (280 points)
My machine have one ETHERNET and one PPP connection. When I try to connect...

FTPClient ftp = new FTPClient();

try {
ftp.setRemoteHost("205.178.145.65");
//ftp.setActiveIPAddress("200.146.64.23");
ftp.connect();
ftp.login("dktnfu&%shj", "9y4jjsr2");

...I get this output the error you can see in the final of this message.
My question is regarding "ftp.setActiveIPAddress("200.146.64.23");".
Once I can

9 Answers

0 votes
by (51.6k points)
The ActiveIPAddress doesn't have anything to do with this, because it's not used until you try to transfer files or get directory listing (in active mode). In this case you can't even establish your initial connection. This is just a straight-forward TCP/IP connection. Can you ping the address? Have you tried a command-line FTP client or an FTP app like FileZilla?

- Hans (EDT)
0 votes
by (280 points)
Yes, I did it whit windows ftp prompt.
What I discovered is that in Windows I have a bridgne connection ( where I get this problem ). The Dial up set a bridge inteface whith a 4.0.x.x ip and ppp assingn an internet IP.
In Linux I can connect without problemns with the same phisical connection.
What I not understant is that another client's run well in windows.

pc -> adsl -> internet

linux: ppp -> internet
windows: ppp -> bridge -> internet
0 votes
by (51.6k points)
Please try the following code snippet to test if this is a general TCP/IP problem:
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;

...

try
{
    IPAddress address = IPAddress.Parse("205.178.145.65");
    IPEndPoint endPoint = new IPEndPoint(address, 21);
    Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    socket.Connect(endPoint);
    Trace.WriteLine("Connected OK");
    socket.Close();
}
catch (Exception ex)
{
    Trace.WriteLine(ex.GetType() + ": " + ex.Message + "\n" + ex.StackTrace);
}


This code works OK on my machine.

- Hans (EDT)
0 votes
by (280 points)
I
0 votes
by (51.6k points)
:oops: Here's a Java version:
import java.net.Socket;

public class TestConnection {
   public static void main(String[] args) {
      try {
         Socket socket = new Socket("205.178.145.65", 21);
         System.out.println("Connected");
         socket.close();
      } catch (Throwable t) {
         t.printStackTrace();
      }
   }
}


- Hans (EDT)
0 votes
by (280 points)
Thanx HANS. There
0 votes
by (51.6k points)
Can you connect to other addressses using my test program? Try some other public FTP servers such as:
  • ftp.gnu.org 199.232.41.7
  • ftp.sun.com 192.18.108.101
  • ftp.microsoft.com 207.46.236.102


- Hans (EDT)
0 votes
by (280 points)
Now we have something... I can connect to this addresses with the ftp from prompt but can
0 votes
by (51.6k points)
That's not necessarily a sign that something is wrong since their router may block pings but not FTP. Please try to connect using the test program I posted just before.

- Hans (EDT)

Categories

...