Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
14.8k views
in Java FTP by (440 points)
Hello Support Team,

We are using EDT Java API to connect with SFTP server. We are getting exception while using wild card e.g. "abc*xyz". In all other cases there is no exception.
Same thing is running smoothly with local server, some of our production servers but one sepcific server is giving this this Exception
Here is the source I used for this, kindly guide:
public void newCodeTestReadingAPIDoc() {
   try {
      SSLFTPClient ftp = new SSLFTPClient();
      ftp.setRemoteHost(remoteHost);
      ftp.setRemotePort(remotePort);
      ftp.setConfigFlags(SSLFTPClient.ConfigFlags.DISABLE_WAIT_ON_CLOSE
            | SSLFTPClient.ConfigFlags.DISABLE_SSL_CLOSURE);
      ftp.setImplicitFTPS(true);
      System.out.println("Importing the server certificate...");
      ftp.getRootCertificateStore().importPEMFile(serverCertPath);
      System.out.println("Connecting to " + remoteHost);
      ftp.connect();
      System.out.println("Auth with PROT PRIVATE.");
      ftp.auth(SSLFTPClient.PROT_PRIVATE);
      System.out.println("Login to " + remoteHost);
      ftp.login(userId, userPw);
      if (ftp.pwd().equals(remotePath) == false) {
         System.out.println("Changing to directory " + remotePath);
         ftp.chdir(remotePath);
      }
      System.out.println("Getting directory listing of: " + remotePath);
      String[] files = ftp.dir(wildCard);
      System.out.println("Total Files Found: " + files.length);
      for (int i = 0; i < files.length; i++) {
         System.out.println("File Name: " + files[i]);
      }
      // close the connection
      ftp.quit();
   } catch (SSLFTPCertificateException e) {
      System.out.println("Failed to connect. Certificates are: ");
      e.printCertificates();
      e.printStackTrace();
   } catch (Exception e) {
      e.printStackTrace();
   }
}


Here is the Exception occured with ft.dir(wildCard) line:
com.enterprisedt.net.puretls.SSLHandshakeFailedException: com.enterprisedt.net.puretls.SSLPrematureCloseException: Short read
at com.enterprisedt.net.puretls.i.G(Unknown Source)
at com.enterprisedt.net.puretls.SSLSocket.handshake(Unknown Source)
at com.enterprisedt.net.ftp.ssl.C.A(Unknown Source)
at com.enterprisedt.net.ftp.ssl.C.getInputStream(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.dir(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.dir(Unknown Source)


Regards,
Faisal Maqsood

15 Answers

0 votes
by (162k points)
So with this one server, everything works fine *except* when you use a wildcard?
0 votes
by (440 points)
Yes

Only ## dir(abc*xyz) ## give short read exception.
Execution of ## dir(abcdxyz) ## has no issue.
0 votes
by (440 points)
I checked with some utility that sftp server is working fine with the utility even with wild card.
But when I run the provided source code, I get Short Read problem on wild card searching.

Kindly share some solution urgently as we are in problem with our production and that is required to resolve ASAP.
0 votes
by (162k points)
Hi, please send a log file set to ALL level to support@enterprisedt.com and we'll examine it ASAP.
0 votes
by (440 points)
thanks for the prompt reply but please guide how to configure log file at all level?
0 votes
by (162k points)
import com.enterprisedt.util.debug.*;

Logger.setLevel(Level.ALL);
Logger.addAppender(new FileAppender("output.log"));
0 votes
by (440 points)
Here is the log file with all LEVEL:
(For security reason, I have updated some private information)
===========================================

INFO [SSLFTPClient] 4 Feb 2008 12:55:28.312 : edtFTPj - PRO version
DEBUG [FTPClient] 4 Feb 2008 12:55:28.328 : Class: com.enterprisedt.net.ftp.ssl.SSLFTPClient
Version: 1.5.3
Build timestamp: 18-Jul-2007 14:22:55 EST
Java version: 1.5.0_01
CLASSPATH: C:\FTPSHandler\src;C:\license-pro.jar;C:\edtftpj-pro.jar
OS name: Windows XP
OS arch: x86
OS version: 5.1

INFO [LicensePropertiesBase] 4 Feb 2008 12:55:28.359 : Licence expiry date: 31 Dec 9999
INFO [LicensePropertiesBase] 4 Feb 2008 12:55:28.359 : Production licence
DEBUG [ProFTPClient] 4 Feb 2008 12:55:28.359 : Class: com.enterprisedt.net.ftp.ssl.SSLFTPClient
Version: 1.5.3
Build timestamp: 18-Jul-2007 14:22:55 EST
Java version: 1.5.0_01
CLASSPATH: C:\FTPSHandler\src;C:\license-pro.jar;C:\edtftpj-pro.jar
OS name: Windows XP
OS arch: x86
OS version: 5.1

DEBUG [CryptixProperties] 4 Feb 2008 12:55:28.500 : Successfully loaded the CryptixEDT properties file
INFO [puretls] 4 Feb 2008 12:55:28.562 : PureTLS debug level=0
DEBUG [SSLFTPClient] 4 Feb 2008 12:55:28.562 : Setting custom validator to com.enterprisedt.net.ftp.ssl.SSLFTPStandardValidator
INFO [cryptix] 4 Feb 2008 12:55:28.687 : GLOBAL_TRACE=false
INFO [cryptix] 4 Feb 2008 12:55:28.687 : GLOBAL_DEBUG=false
INFO [cryptix] 4 Feb 2008 12:55:28.687 : GLOBAL_DEBUG_SLOW=false
DEBUG [SSLFTPClient] 4 Feb 2008 12:55:28.781 : Turned server validation off
DEBUG [SSLFTPClient] 4 Feb 2008 12:55:28.781 : Created implicit FTPS client.
DEBUG [SSLFTPClient] 4 Feb 2008 12:55:28.781 : Connecting to SFTP.MYDOMAIN.com/123.123.123.123:990
DEBUG [SSLSocketUtils] 4 Feb 2008 12:55:28.796 : Invoking connect with timeout=60000
DEBUG [IJCE_Properties] 4 Feb 2008 12:55:29.859 : Successfully loaded the IJCE properties file
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:30.781 : 220-Glub Tech Secure FTP Wrapper (v2.5.7)
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:30.781 : 220 Welcome to XXX FTP service.
DEBUG [SSLFTPControlSocket] 4 Feb 2008 12:55:30.781 : DISABLE_CONTROL_SSL_CLOSURE=true
DEBUG [SSLFTPControlSocket] 4 Feb 2008 12:55:30.781 : DISABLE_CONTROL_WAIT_ON_CLOSE=true
DEBUG [SSLFTPControlSocket] 4 Feb 2008 12:55:30.781 : ALLOW_BASIC_CONSTRAINTS_IN_NON_CA=false
DEBUG [SSLFTPControlSocket] 4 Feb 2008 12:55:30.781 : SSL handshake completed on control channel
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:30.781 : ---> PBSZ 0
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.93 : 200 PBSZ Command OK. Protection buffer size set to 0.
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.93 : ---> PROT P
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.421 : 200 PROT Command OK. Using Private data connection.
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.421 : ---> USER XXXXXXX
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.734 : 331 Please specify the password.
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:31.734 : ---> PASS XXXXXXX
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.312 : 230 Login successful.
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.312 : ---> PWD
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.625 : 257 "/home/XXXXXXX"
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.625 : ---> CWD /home/XXXXXXX
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.953 : 250 Directory successfully changed.
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:32.953 : ---> PASV
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:33.281 : 227 Entering Passive Mode (123,123,123,123,11,209)
DEBUG [SSLFTPControlSocket] 4 Feb 2008 12:55:33.281 : Creating SSLFTPPassiveDataSocket
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:33.593 : ---> NLST abc*.xyz
DEBUG [FTPControlSocket] 4 Feb 2008 12:55:33.921 : 150 Here comes the directory listing.
DEBUG [SSLFTPPassiveDataSocket] 4 Feb 2008 12:55:33.921 : Starting SSL handshake on passive data socket
DEBUG [SSLFTPPassiveDataSocket] 4 Feb 2008 12:55:33.937 : Closing passive data socket



Regards,
Faisal Maqsood
0 votes
by (162k points)
There is no obvious reason why this is failing. However many servers do not support using wildcards in this way (there is no guarantee in the FTP standard that they should), and it may be that the client that succeeded does the wildcarding on the client side.

A simple solution is to use "." to list the entire directory and then prune out entries you don't want after you receive the list.

Of course if this doesn't work, there is another problem. Have you successfully performed any file transfers or directory listings on this server? The error does have the look of a connection being severed by a firewall.
0 votes
by (440 points)
Yes we can download/upload files to this server without any problem.

We are using Glub server and same server is intalled locally for testing but local testing server is working fine with wild card filter.
On our production, we also tried without firewall but same problem of Short Read while using wildcard filter.

Regards,
Faisal Maqsood
0 votes
by (162k points)
Ok, so ordinary listings work fine against this same server, but wildcard listings don't? (but they do work when the server is running locally). Very weird.

2 things to do - get the server log and email it to us, and get the detailed client logs (set the system property edtftp.log.puretls.level=65535) and email to us (support@enterprisedt.com).

Please don't post long log files here.

Categories

...