2 Replies Latest reply on Apr 27, 2005 4:31 PM by Krupa Natarajan

    Socket connection timeout fter idle time

    Krupa Natarajan Newbie

      Hi all,
      I am running JBOSS 4.0.1 on Windows. I have a client code within Jboss that connects to the same jboss server URL (this is part of CAS authentication).
      All is well when Jboss starts up initially. But if I leave my Jboss server running overnight and try accessing it after a period of inactivity, I get a connection refused exception during socket connect. The server responds with the same URL from the browser window. My code snippet and exception log are given below.

      I really appretiate your help on this ! Thanks !!

      /************* CODE ***************/
      URL u = new URL(url);
      if (!u.getProtocol().equals("https"))
      throw new IOException("only 'https' URLs are valid for this method");
      URLConnection uc = u.openConnection();
      uc.setRequestProperty("Connection", "close");
      r = new BufferedReader(new InputStreamReader(uc.getInputStream()));

      -------> The getInputStream() is from where the exception is thrown !!!

      /*************** EXCEPTION LOGS *************/
      java.net.ConnectException: Connection timed out: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:452)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA6275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.(DashoA6275)
      at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(DashoA6275)
      at sun.net.www.protocol.https.HttpsClient.doConnect(DashoA6275)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
      at sun.net.www.protocol.https.HttpsClient.(DashoA6275)
      at sun.net.www.protocol.https.HttpsClient.a(DashoA6275)
      at sun.net.www.protocol.https.HttpsClient.a(DashoA6275)
      at sun.net.www.protocol.https.HttpsClient.a(DashoA6275)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.plainConnect(DashoA6275)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA6275)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:617)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(DashoA6275)
      at edu.yale.its.tp.cas.util.SecureURL.retrieve(Unknown Source)


        • 1. Re: Socket connection timeout fter idle time
          Scott Marlowe Newbie

          Is there a firewall between your app and db server? If so (and maybe even if not) try changing your tcp_keepalive_time setting. It's a registry setting, and I don't know how to set it (I'm a Unix guy, sorry) but a google search should turn it up pretty quick.

          • 2. Re: Socket connection timeout fter idle time
            Krupa Natarajan Newbie

            Thanks for ur response!
            There is no firewall between my app and database as I am running on a dev environment. Also the same application when run on tomcat against the same database (which we have been doing for a while now) has never encountered this issue.

            What I am noticing now is that whether jboss is active or not I still get the connection timeout when the server has been up for a long time (about 14 hours). Also just to clarify, this is not a databse timeout but the timeout happens when the client code opens a URLConnection to the jboss url.

            Thanks again !