Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12k views
in Java FTP by (200 points)
I am using the following code to ftp a file:
FileTransferClient ftp = null;
try {
   ftp = new FileTransferClient();
   ftp.setRemoteHost(custInfo.getFtpAddress());
   if(custInfo.getPort() > 0)
      ftp.setRemotePort(custInfo.getPort());
   ftp.setUserName(custInfo.getFtpUser());
   ftp.setPassword(custInfo.getFtpPassword());
   log.info("Connecting to server " + custInfo.getFtpAddress());
   ftp.connect();
   log.info("Connected and logged in to server " + custInfo.getFtpAddress());
   ftp.setContentType(FTPTransferType.BINARY);
   if(custInfo.getFtpDirectory() != null) 
      ftp.changeDirectory(custInfo.getFtpDirectory());
   ftp.uploadFile(file.getAbsolutePath(), file.getName());
} catch (Exception e) {
   log.error("Transmission failed",e);
} finally {
    try {
   log.info("Quitting client");
   if (ftp != null)
       ftp.disconnect();
    } catch (Exception e) {
   log.error("Error in disconnecting ftp connection", e);
    }
}


I got the "com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out" Error. This issue is not consistent. The next time i ran this code, it works fine.

LOG:
Location: file:/home/usr/app/lib/edtftpj.jar
Version: 2.0.5
Build timestamp: 19-Oct-2009 13:44:01 EST
Java version: 1.5.0_17
CLASSPATH: app.jar
OS name: SunOS
OS arch: x86
OS version: 5.10

FileTransferClient - Configured client
FTPClient - Connecting to <SERVER_NAME>
FTPControlSocket - Read failed ('' read so far)
FTPControlSocket - Failed to initialize control socket
com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1014)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1049)
at com.enterprisedt.net.ftp.FTPControlSocket.validateConnection(FTPControlSocket.java:418)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:384)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:355)
at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:958)
at com.enterprisedt.net.ftp.FileTransferClient.connect(FileTransferClient.java:383)
at FtpUtil.transferFile(Unknown Source)
at Main.execute(Unknown Source)
at Main.main(Unknown Source)

Is there any solution to this problem?

Thanks,
sassubra

10 Answers

0 votes
by (162k points)
Enable logging at DEBUG level and post the relevant piece of the log file.
0 votes
by (200 points)
LOG:

DEBUG 09 May 08:05:08 [main] FTPClient - Class: com.enterprisedt.net.ftp.FTPClient
Location: file:/home/sassubra/ftpapp/lib/edtftpj.jar
Version: 2.0.5
Build timestamp: 19-Oct-2009 13:44:01 EST
Java version: 1.5.0_17
CLASSPATH: ftpapp.jar
OS name: SunOS
OS arch: x86
OS version: 5.10

INFO 09 May 08:05:08 [main] com.work.ftp.FtpUtil - Connecting to server
DEBUG 09 May 08:05:08 [main] FileTransferClient - Configured client
DEBUG 09 May 08:05:08 [main] FTPClient - Connecting to server
ERROR 09 May 08:06:08 [main] FTPControlSocket - Read failed ('' read so far)
ERROR 09 May 08:06:08 [main] FTPControlSocket - Failed to initialize control socket
com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1014)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1049)
at com.enterprisedt.net.ftp.FTPControlSocket.validateConnection(FTPControlSocket.java:418)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:384)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:355)
at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:958)
at com.enterprisedt.net.ftp.FileTransferClient.connect(FileTransferClient.java:383)
at com.work.ftp.FtpUtil.transferFile(Unknown Source)
at com.work.ftp.Main.execute(Unknown Source)
at com.work.ftp.Main.main(Unknown Source)
0 votes
by (51.6k points)
As you probably have gathered from the logs, the server accepts the connection from the client, but then fails to send the initial welcome message, thus causing the client to time out after a minute. This is sometimes an indication that the port you have connected to is not an FTP server, but the fact that it works sometimes would indicate that it is. There really aren't any other clues in the log, so it's hard to guess what's going on. It seems pretty clear that it's a server error though. Are you able to inspect the server logs? Do other clients, such as FileZilla display the same behaviour?

- Hans (EnterpriseDT)
0 votes
by (260 points)
Hi...

I am getting following exception .. can someone please help and suggest what could be possible cause of this exception?


com.enterprisedt.net.ftp.ControlChannelIOException : Short read

Thanks a lot...

Regards,
sunafi.
0 votes
by (162k points)
The 'short read' message happens during FTPS sessions when the remote server suddenly closes the socket. The first place to check for a reason for this is the server logs. It could also be a firewall.
0 votes
by (260 points)
Much appreciate quick reply...


Regarding Firewall possibility - Logs are having this exception randomly ... for couple of instances... but working fine for rest of the requests... can you please suggest still this could be firewall issue, since works for most of requests..

Please advise...
0 votes
by (162k points)
Post a snippet of the client and server logs.
0 votes
by (260 points)
Issue is occurring very frequently and log file has so many occurrence with this...
can someone please suggest me on this issue.

com.enterprisedt.net.ftp.ControlChannelIOException: Short read
at com.enterprisedt.net.ftp.FTPControlSocket.e(FTPControlSocket.java:1041)
at com.enterprisedt.net.ftp.FTPControlSocket.b(FTPControlSocket.java:1076)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:1000)
at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:4184)

....
....
....
....
....
....
....

at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
....
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1071)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:84)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:816)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1700)
0 votes
by (260 points)
com.enterprisedt.net.ftp.ControlChannelIOException: Short read
at com.enterprisedt.net.ftp.FTPControlSocket.e(FTPControlSocket.java:1041)
at com.enterprisedt.net.ftp.FTPControlSocket.b(FTPControlSocket.java:1076)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:1000)
at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:4184)


FTPClient.quit
does that mean quit is called but connection is already closed?
0 votes
by (162k points)
Yes, it looks like the connection is already terminated.

Categories

...