Thrift
  1. Thrift
  2. THRIFT-1523

clientTimeout not worked as expected in TServerSocket created by TSSLTransportFactory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.6.1, 0.7, 0.8, 0.9
    • Fix Version/s: 0.9
    • Component/s: Java - Library
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      TSSLTransportFactory has method

      public static TServerSocket getServerSocket(int port, int clientTimeout)

      there is parameter clientTimeout that need to close idle client connections (after clientTimeout amount of millis of client inactivity server closes opened connection themself, not waiting while client called close() method). This parameter work fine when create TServerSocket through new, but not working at all when creating TServerSocket through TSSLTransportFactory.getServerSocket

      1. clientTimeout.patch
        0.5 kB
        Alexey Sviridov

        Activity

        Hide
        Alexey Sviridov added a comment -

        After a little explain i'm found method createServer(SSLServerSocketFactory factory, int port, int timeout,... that creates TServerSocket by return new TServerSocket(serverSocket);

        this method used timeout parameter with wrong way - by setting serverSocket.setSoTimeout(timeout); but this is no matter because this timeout setted on server socket and affect only accept() method, and not used for read timeout as desired (btw, later in methos listen() even serverSocket soTimeout setted to 0). For properly handle clientTimeout we need call setSoTimeout on client socket, after we accepted them. This done in method acceptImpl(), but there used internal field clientTimeout_ stored in constucot of TServerSocket!!! (result2.setTimeout(clientTimeout_); ) but, as i'm mentioned before, in createServer TServerSocket created by new TServerSocket(serverSocket); This called constructor TServerSocket(serverSocket,0) and set internal field clientTimeout_ to 0, what mean wait infinite!

        so we only need replace line

        return new TServerSocket(serverSocket);
        by
        return new TServerSocket(serverSocket,timeout); in TSSLTransportFactory.createServer method

        Show
        Alexey Sviridov added a comment - After a little explain i'm found method createServer(SSLServerSocketFactory factory, int port, int timeout,... that creates TServerSocket by return new TServerSocket(serverSocket); this method used timeout parameter with wrong way - by setting serverSocket.setSoTimeout(timeout); but this is no matter because this timeout setted on server socket and affect only accept() method, and not used for read timeout as desired (btw, later in methos listen() even serverSocket soTimeout setted to 0). For properly handle clientTimeout we need call setSoTimeout on client socket, after we accepted them. This done in method acceptImpl(), but there used internal field clientTimeout_ stored in constucot of TServerSocket!!! ( result2.setTimeout(clientTimeout_); ) but, as i'm mentioned before, in createServer TServerSocket created by new TServerSocket(serverSocket); This called constructor TServerSocket(serverSocket,0) and set internal field clientTimeout_ to 0, what mean wait infinite! so we only need replace line return new TServerSocket(serverSocket); by return new TServerSocket(serverSocket,timeout); in TSSLTransportFactory.createServer method
        Hide
        Alexey Sviridov added a comment - - edited

        patch for solving problem with clientTimeout. Patch for version 0.9

        Show
        Alexey Sviridov added a comment - - edited patch for solving problem with clientTimeout. Patch for version 0.9
        Hide
        Jake Farrell added a comment -

        Committed, thanks for the patch

        Show
        Jake Farrell added a comment - Committed, thanks for the patch
        Hide
        Hudson added a comment -

        Integrated in Thrift #422 (See https://builds.apache.org/job/Thrift/422/)
        THRIFT-1523: clientTimeout not worked as expected in TServerSocket created by TSSLTransportFactory
        Client: java
        Patch: Alexey Sviridov

        Adds server timeout to SSLTransportFactory (Revision 1296053)

        Result = SUCCESS
        jfarrell : http://svn.apache.org/viewvc/?view=rev&rev=1296053
        Files :

        • /thrift/trunk/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java
        Show
        Hudson added a comment - Integrated in Thrift #422 (See https://builds.apache.org/job/Thrift/422/ ) THRIFT-1523 : clientTimeout not worked as expected in TServerSocket created by TSSLTransportFactory Client: java Patch: Alexey Sviridov Adds server timeout to SSLTransportFactory (Revision 1296053) Result = SUCCESS jfarrell : http://svn.apache.org/viewvc/?view=rev&rev=1296053 Files : /thrift/trunk/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java

          People

          • Assignee:
            Alexey Sviridov
            Reporter:
            Alexey Sviridov
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development