Menu

#290 Portmapper.getServerSocket does not time out

Sign-on
closed-fixed
Paul D
None
5
2008-09-02
2008-08-05
DominikM
No

Hi,

we're writing an application which needs to reconnect to an iSeries after it was gone. We're using JDBC to query a database and observed the following problem:

When the connection to the system is terminated (pulled cable or deleted route) the JDBC query sometimes waits indefinitely for a response. There is no way to stop it neither by setting a time out on the DriverManager or on the Statement itself.

After a few debugging sessions we determined the problem to be in PortMapper.getServerSocket in the following code:

if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Opening socket to system...");

Socket socket = new Socket(systemName, srvPort);

PortMapper.setSocketProperties(socket, socketProperties);

The application hangs in the creation of the socket object. The explanation lies within the Socket class. the Socket constructors do not allow to set a connection timeout and default to 0 which means infinite.

Changing the line to:

Socket socket = new Socket();
socket.connect(new InetSocketAddress(systemName, srvPort), socketProperties.getSoTimeout());

or another large enough number solves the problem.

Is it possible to fix this in a future version?

If you have any more questions feel free to contact me.

Thanks

Dominik

Discussion

  • Jeff Lee

    Jeff Lee - 2008-08-05
    • assigned_to: nobody --> pauldevman
     
  • Paul D

    Paul D - 2008-08-05

    Logged In: YES
    user_id=1359486
    Originator: NO

    Dominik:

    We have recently found the same issue. We put a fix for this into JTOpen 6.2. Also java 1.4 or higher is required for this.

     
  • Paul D

    Paul D - 2008-08-05
    • status: open --> closed
     
  • DominikM

    DominikM - 2008-08-05

    Logged In: YES
    user_id=1522446
    Originator: YES

    Hi,

    unfortunately this does not solve our problem. We're already using the latest version (6.2) and the code I mentioned is in line 249. I've read your source code comment a few lines above and I think that your fix is also needed a few lines down :)

    Can I help you with anything to further prove my point? If so, please let me know :)

     
  • DominikM

    DominikM - 2008-08-05
    • status: closed --> open
     
  • DominikM

    DominikM - 2008-08-05

    Logged In: YES
    user_id=1522446
    Originator: YES

    A stack trace showing the problem. The application stays like this forever (not tested that but I've waited long enough :))

    Name: main
    State: RUNNABLE
    Total blocked: 0 Total waited: 17

    Stack trace:
    java.net.PlainSocketImpl.socketConnect(Native Method)
    java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    - locked java.net.SocksSocketImpl@19ba1d8
    java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    java.net.Socket.connect(Socket.java:519)
    java.net.Socket.connect(Socket.java:469)
    java.net.Socket.<init>(Socket.java:366)
    java.net.Socket.<init>(Socket.java:180)
    com.ibm.as400.access.PortMapper.getServerSocket(PortMapper.java:249)
    com.ibm.as400.access.AS400ImplRemote.signonConnect(AS400ImplRemote.java:1930)
    - locked com.ibm.as400.access.AS400ImplRemote@15291cd
    com.ibm.as400.access.AS400ImplRemote.signon(AS400ImplRemote.java:1849)
    com.ibm.as400.access.AS400.sendSignonRequest(AS400.java:2585)
    com.ibm.as400.access.AS400.promptSignon(AS400.java:2156)
    com.ibm.as400.access.AS400.signon(AS400.java:3426)
    - locked com.ibm.as400.access.AS400@1d4eeb5
    com.ibm.as400.access.AS400.connectService(AS400.java:877)
    com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3017)
    com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1256)
    com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1107)
    com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:357)

     
  • Nobody/Anonymous

    Logged In: NO

    Yes, I see the code you are pointing to.
    We will update this also.
    Thanks for the heads-up on this.

     
  • Jeff Lee

    Jeff Lee - 2008-08-14

    Logged In: YES
    user_id=1221895
    Originator: NO

    Paul has integrated the fix for inclusion in the next release of JTOpen (due out within the next few weeks). You may view the updated source code in the CVS repository.

     
  • Jeff Lee

    Jeff Lee - 2008-08-14
    • status: open --> pending-fixed
     
  • Jeff Lee

    Jeff Lee - 2008-09-02

    Logged In: YES
    user_id=1221895
    Originator: NO

    Fixed in JTOpen 6.3, which is now available.

     
  • Jeff Lee

    Jeff Lee - 2008-09-02
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.