commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dany Alain (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (NET-661) FTPSClient hang java.net.SocketInputStream.socketRead0 while doing SSL Handshake - Socket timeout not set
Date Mon, 11 Jun 2018 19:53:00 GMT

     [ https://issues.apache.org/jira/browse/NET-661?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Dany Alain updated NET-661:
---------------------------
    Description: 
In a lab with unstable connection we have our FTP client hanging forever (e.g. 36 hours ->
base on our linux kernel configuration)
{quote}java.lang.Thread.State: RUNNABLE
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
 at java.net.SocketInputStream.read(SocketInputStream.java:171)
 at java.net.SocketInputStream.read(SocketInputStream.java:141)
 at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
 at sun.security.ssl.InputRecord.read(InputRecord.java:503)
 at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
 locked <0x00000000ae243608> (a java.lang.Object)
 at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
 locked <0x00000000ae243620> (a java.lang.Object)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
 at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:289)
 at org.apache.commons.net.ftp.FTPSClient.connectAction(FTPSClient.java:220)
 at org.apache.commons.net.SocketClient._connect(SocketClient.java:244)
 at org.apache.commons.net.SocketClient.connect(SocketClient.java:202)
 at com.ericsson.mdn.logaccu.ftp.FTPClientWrapper.connectAndLogin(FTPClientWrapper.java:100)
 at com.ericsson.mdn.logaccu.ftppull.ResourceFTPJob.run(ResourceFTPJob.java:122)
 at
 com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.doWork(ThreadWorker.java:160)
 at com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.run(ThreadWorker.java:69)
{quote}
our code
{quote}final FTPSClient client = new FTPSClient("TLSv1.2", true);
 // load the trust store& key store 
 client.setDataTimeout(1000);
 client.setControlKeepAliveReplyTimeout(1000);
 client.setControlKeepAliveTimeout(1000);
 client.setDefaultTimeout(1000);
 client.setConnectTimeout(1000);
 client.connect(host, port); // hang randomly
 client.setSoLinger(true, 10); // cannot be call before, socket is null 
 reply = client.getReplyCode();
{quote}
After looking at the FTP, FTPSClient code and reading on internet I realize that in the case
of an implicit connection the Socket is initialized with So timeout of 0 because "_connectAction_()"
is overwritten

*Socket.java*
{quote}protected void _connectAction_() throws IOException
     *_socket_.setSoTimeout(_timeout_);*
     _input_ = _socket_.getInputStream(); 
     _output_ = _socket_.getOutputStream(); }
{quote}
*FTPSClient.java*
{quote}@Override

protected void _connectAction_() throws IOException {

    // Implicit mode.
      if (isImplicit) {
          *sslNegotiation();* {color:#ff0000}// hangs at java.net.SocketInputStream.socketRead0(Native
Method){color}
      }
      super._connectAction_(); *{color:#ff0000}// setSoTimeout will be set here - but
too late{color}*
      // Explicit mode.
      if (!isImplicit)
 Unknown macro: \{        execAUTH();      }
 }
{quote}
So *workaround* for now is to overwrite FTPSClient-> _connectAction_()
{quote}new FTPSClient(...)

{
 @Override 
 protected void _connectAction_() throws IOException  
{        _socket_.setSoTimeout(_timeout_);     super._connectAction_(); }
};
{quote}

  was:
In a lab with unstable connection we have our FTP client hanging forever (e.g. 36 hours ->
base on our linux kernel configuration)
{quote}java.lang.Thread.State: RUNNABLE
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
 at java.net.SocketInputStream.read(SocketInputStream.java:171)
 at java.net.SocketInputStream.read(SocketInputStream.java:141)
 at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
 at sun.security.ssl.InputRecord.read(InputRecord.java:503)
 at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
 locked <0x00000000ae243608> (a java.lang.Object)
 at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
 locked <0x00000000ae243620> (a java.lang.Object)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
 at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:289)
 at org.apache.commons.net.ftp.FTPSClient.connectAction(FTPSClient.java:220)
 at org.apache.commons.net.SocketClient._connect(SocketClient.java:244)
 at org.apache.commons.net.SocketClient.connect(SocketClient.java:202)
 at com.ericsson.mdn.logaccu.ftp.FTPClientWrapper.connectAndLogin(FTPClientWrapper.java:100)
 at com.ericsson.mdn.logaccu.ftppull.ResourceFTPJob.run(ResourceFTPJob.java:122)
 at
 com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.doWork(ThreadWorker.java:160)
 at com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.run(ThreadWorker.java:69)
{quote}
our code
{quote}final FTPSClient client = new FTPSClient("TLSv1.2", true);
 // load the trust store& key store 
 client.setDataTimeout(1000);
 client.setControlKeepAliveReplyTimeout(1000);
 client.setControlKeepAliveTimeout(1000);
 client.setDefaultTimeout(1000);
 client.setConnectTimeout(1000);
 client.connect(host, port); // hang randomly
 client.setSoLinger(true, 10); // cannot be call before, socket is null 
 reply = client.getReplyCode();
{quote}
After looking at the FTP, FTPSClient code and reading on internet I realize that in the case
of an implicit connection the Socket is initialized with So timeout of 0 because "_connectAction_()"
is overwritten

*Socket.java*
{quote}protected void _connectAction_() throws IOException
     *_socket_.setSoTimeout(_timeout_);*
     _input_ = _socket_.getInputStream(); 
     _output_ = _socket_.getOutputStream(); }
{quote}
*FTPSClient.java*
{quote}@Override

protected void _connectAction_() throws IOException {

    // Implicit mode.
      if (isImplicit) {
          *sslNegotiation();* {color:#ff0000}// hangs at java.net.SocketInputStream.socketRead0(Native
Method){color}
      }
      super._connectAction_(); *{color:#ff0000}// setSoTimeout will be set here - but
too late{color}*
      // Explicit mode.
      if (!isImplicit)
Unknown macro: \{        execAUTH();      }
}
{quote}
So *workaround* for now is to overwrite FTPSClient-> _connectAction_()
{quote}new FTPSClient(...)
@Override 
protected void _connectAction_() throws IOException   {
      // FTPS stuck in socketRead0
     _socket_.setSoTimeout(_timeout_);
     super._connectAction_(); }
};
{quote}


> FTPSClient hang java.net.SocketInputStream.socketRead0 while doing SSL Handshake - Socket
timeout not set
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: NET-661
>                 URL: https://issues.apache.org/jira/browse/NET-661
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.6
>         Environment: Apache NET 3.6
>  
> #uname -a
> Linux myhost 2.6.32-696.23.1.el6.x86_64 #1 SMP Sat Feb 10 11:10:31 EST 2018 x86_64 x86_64
x86_64 GNU/Linux
> # java -version
> openjdk version "1.8.0_171"
> OpenJDK Runtime Environment (build 1.8.0_171-b10)
> OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
>  
>  
>            Reporter: Dany Alain
>            Priority: Major
>              Labels: SocketTimeout, hang, implicit, socketRead0, ssl
>
> In a lab with unstable connection we have our FTP client hanging forever (e.g. 36 hours
-> base on our linux kernel configuration)
> {quote}java.lang.Thread.State: RUNNABLE
>  at java.net.SocketInputStream.socketRead0(Native Method)
>  at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
>  at java.net.SocketInputStream.read(SocketInputStream.java:171)
>  at java.net.SocketInputStream.read(SocketInputStream.java:141)
>  at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
>  at sun.security.ssl.InputRecord.read(InputRecord.java:503)
>  at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
>  locked <0x00000000ae243608> (a java.lang.Object)
>  at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
>  locked <0x00000000ae243620> (a java.lang.Object)
>  at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
>  at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
>  at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:289)
>  at org.apache.commons.net.ftp.FTPSClient.connectAction(FTPSClient.java:220)
>  at org.apache.commons.net.SocketClient._connect(SocketClient.java:244)
>  at org.apache.commons.net.SocketClient.connect(SocketClient.java:202)
>  at com.ericsson.mdn.logaccu.ftp.FTPClientWrapper.connectAndLogin(FTPClientWrapper.java:100)
>  at com.ericsson.mdn.logaccu.ftppull.ResourceFTPJob.run(ResourceFTPJob.java:122)
>  at
>  com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.doWork(ThreadWorker.java:160)
>  at com.ericsson.mdn.daedalus.threadpool.queued.ThreadWorker.run(ThreadWorker.java:69)
> {quote}
> our code
> {quote}final FTPSClient client = new FTPSClient("TLSv1.2", true);
>  // load the trust store& key store 
>  client.setDataTimeout(1000);
>  client.setControlKeepAliveReplyTimeout(1000);
>  client.setControlKeepAliveTimeout(1000);
>  client.setDefaultTimeout(1000);
>  client.setConnectTimeout(1000);
>  client.connect(host, port); // hang randomly
>  client.setSoLinger(true, 10); // cannot be call before, socket is null 
>  reply = client.getReplyCode();
> {quote}
> After looking at the FTP, FTPSClient code and reading on internet I realize that in the
case of an implicit connection the Socket is initialized with So timeout of 0 because "_connectAction_()"
is overwritten
> *Socket.java*
> {quote}protected void _connectAction_() throws IOException
>      *_socket_.setSoTimeout(_timeout_);*
>      _input_ = _socket_.getInputStream(); 
>      _output_ = _socket_.getOutputStream(); }
> {quote}
> *FTPSClient.java*
> {quote}@Override
> protected void _connectAction_() throws IOException {
>     // Implicit mode.
>       if (isImplicit) {
>           *sslNegotiation();* {color:#ff0000}// hangs at java.net.SocketInputStream.socketRead0(Native
Method){color}
>       }
>       super._connectAction_(); *{color:#ff0000}// setSoTimeout will be set here -
but too late{color}*
>       // Explicit mode.
>       if (!isImplicit)
>  Unknown macro: \{        execAUTH();      }
>  }
> {quote}
> So *workaround* for now is to overwrite FTPSClient-> _connectAction_()
> {quote}new FTPSClient(...)
> {
>  @Override 
>  protected void _connectAction_() throws IOException  
> {        _socket_.setSoTimeout(_timeout_);     super._connectAction_(); }
> };
> {quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message