3 Replies Latest reply on Jul 22, 2008 4:43 PM by Jeremy Vosters

    Client timeout

    Robert Jaros Newbie

      I've read many different comments about this subject on this forum and tried all of them but without luck. I'm trying to set timeout on web service call. My code looks like this:

      Service service = Service.create(wsdlLocation, serviceName);
      BWSRemoteInterface port = (BWSRemoteInterface) service.getPort(new QName(url, "http://url"),BWSRemoteInterface.class);
      


      I've tried this, hoping it will work:
      ((BindingProvider)port).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, new Integer(500));


      but it doesn't. I'm using JBoss 4.2.1 and JBossWS 2.0.1. My WS timeouts always after about 3 minutes. I would be very grateful for any help.


        • 1. Re: Client timeout
          Jeremy Vosters Newbie

          Hello -

          I was wondering if any discoveries have been made on this post. I had attempted similar code in the 3.0.2 GA release of jbossws and also could not get the timeout to occur. Really, what is needed is to have the socket throw and exception if the response does not come back in an acceptable time frame.

          Thank you for any help and it would be greatly appreciated.

          • 2. Re: Client timeout
            Robert Jaros Newbie

            In fact I have found a simple solution to this problem. Try setting

            -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=10000

            properties of the JVM (both values are in milliseconds). It works for me. And I'm still using
            ((BindingProvider)port).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, new Integer(500));
            as well, because sometimes it is necessery (I think when I can connect to remote side but I don't get any answer for a long time).

            • 3. Re: Client timeout
              Jeremy Vosters Newbie

              Thank you very much. That worked beautifully.