ftp4j中的套接字超时,用于使用http代理的FTP连接

时间:2015-03-11 02:41:18

标签: java sockets apache-commons-httpclient http-tunneling ftp4j

我正在为ftp客户端使用ftp4j jar我使用了HTTP隧道连接器,因为我的FTP服务器(打开VMS服务器)位于HTTP代理之后。像PWD,NOOP,CWD这样的基本命令工作正常,但如果我尝试LIST& NLIST一个目录或STOR文件什么都不会发生,我会得到SocketTimeOutException。

下面是我的代码

HTTPTunnelConnector httpTunnelConnector =  new HTTPTunnelConnector("**********", 80);
          httpTunnelConnector.setConnectionTimeout(100);

FTPCommunicationListener ftpCommunicationListener = new FTPCommunicationListener()
          {     
                 @Override
                 public void sent(String command)
                 {
                       System.out.println("SENT      :: "+command);
                 }

                 @Override
                 public void received(String response)
                 {
                       System.out.println("RECEIVED   :: "+response);
                 }
          };    


    FTPClient ftpClient = new FTPClient();
    ftpClient.addCommunicationListener(ftpCommunicationListener);
                 ftpClient.setConnector(httpTunnelConnector);

                 System.out.println("Connecting to  FTP server ... ");
                 String[] connectResponse = ftpClient.connect("*********", 21);
                 for (String string : connectResponse) {
                       System.out.println(string);
                 }

                 System.out.println("logging to FTP server ...");
                 ftpClient.login("ftpsee", "seeftp");

                 System.out.println("Authenticated by FTP server :: "+ftpClient.isAuthenticated());
                 ftpClient.setPassive(true);

                 File file = new File(argument);
                       ftpClient.upload(file);

如果我将注释掉我将HTTPTunnelConnector添加到我的FTP客户端的部分,那么我的代码工作正常(但我会在内部使用FTPTunnelConnector)

下面是我的错误消息 java.net.SocketTimeoutException:读取超时

0 个答案:

没有答案