You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "Marepalli, Hanumantha Rao" <Ha...@iona.com> on 2007/06/01 13:13:40 UTC

How to modify the default client connection timeout value?

Hi,

 

I'm running concurrent clients; each client sends requests to the
endpoint for a specified duration, say 5 minutes. Some of my clients get
"java.net.ConnectException: Cannot assign requested address" while
establishing connection to the server. To rule out the possibility of
connection timeout, I increased client connection/receive timeout values
to 5 minutes through configuration, but it did not make any difference.


 

So wondering whether the following approach to modify the client
connection/receive timeout values is correct (The endpointName of my
service is SoapPort and it is listening on 20003 port) -

 

1. I created xml config file (cxf-config.xml) with the following info -

 

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:http="http://cxf.apache.org/transports/http/configuration"

       xsi:schemaLocation="

http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schema/transports/http.xsd

http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

 

    <http:conduit
id="{http://cxf.apache.org/performance/complex_type}SoapPort20003.http-c
onduit">

        <http:client ConnectionTimeout="300000"
ReceiveTimeout="300000"/>

    </http:conduit>

</beans>

 

2. Supplied the "cxf-config.xml" file as an argument to the
cxf.client.run macro, like
jvmarg1="-Dcxf.config.file=wsdl/cxf-config.xml

 

Does anyone confirm the way I configured is correct? Is there anyway to
find out whether the timeout value that I specified has actually been
picked up? It does not seem to be making any difference, even I set
reduce the timeout value to 1 ms (my invocation takes about 10 ms).

 

Thanks and Regards

Rao


RE: How to modify the default client connection timeout value?

Posted by "Glynn, Eoghan" <eo...@iona.com>.
 

> Similarly you can set this value programmatically:
> 
>     policy.getConnectionTimeout(300000);
            ^^^

I meant to write:

      policy.setConnectionTimeout(300000);

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

RE: How to modify the default client connection timeout value?

Posted by "Glynn, Eoghan" <eo...@iona.com>.
 

Hi Rao,


> Is there 
> anyway to find out whether the timeout value that I specified 
> has actually been picked up?


You can programmatically navigate from your proxy (e.g. the Greeter
instance) to the effective HTTPClientPolicy (into which your configured
timeout should have been injected) as follows:

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

//...

    Client client = ClientProxy.getClient(greeter);
    HTTPConduit conduit = (HTTPConduit)client.getConduit();
    HTTPClientPolicy policy = conduit.getClient();
    System.out.println("connection timeout: " +
policy.getConnectionTimeout());

Similarly you can set this value programmatically:

    policy.getConnectionTimeout(300000);


> It does not seem to be making 
> any difference, even I set reduce the timeout value to 1 ms 
> (my invocation takes about 10 ms).


Remember, this is a connection establishment timeout, not an invocation
timeout. So your configured 1ms value bounds the time available to
establish the connection, *not* the time required to deliver the request
and receive the response.

If you want to set the overall invocation timeout, you can do so
programmatically (to say 30 seconds) via:

    ((ClientImpl)client).setSynchronousTimeout(30 * 1000);

Cheers,
Eoghan 

> -----Original Message-----
> From: Marepalli, Hanumantha Rao [mailto:Hanumantha.Rao@iona.com] 
> Sent: 01 June 2007 12:14
> To: cxf-dev@incubator.apache.org
> Subject: How to modify the default client connection timeout value?
> 
> Hi,
> 
>  
> 
> I'm running concurrent clients; each client sends requests to 
> the endpoint for a specified duration, say 5 minutes. Some of 
> my clients get
> "java.net.ConnectException: Cannot assign requested address" 
> while establishing connection to the server. To rule out the 
> possibility of connection timeout, I increased client 
> connection/receive timeout values to 5 minutes through 
> configuration, but it did not make any difference.
> 
> 
>  
> 
> So wondering whether the following approach to modify the 
> client connection/receive timeout values is correct (The 
> endpointName of my service is SoapPort and it is listening on 
> 20003 port) -
> 
>  
> 
> 1. I created xml config file (cxf-config.xml) with the 
> following info -
> 
>  
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <beans xmlns="http://www.springframework.org/schema/beans"
> 
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 
>        
> xmlns:http="http://cxf.apache.org/transports/http/configuration"
> 
>        xsi:schemaLocation="
> 
> http://cxf.apache.org/transports/http/configuration
> http://cxf.apache.org/schema/transports/http.xsd
> 
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd">
> 
>  
> 
>     <http:conduit
> id="{http://cxf.apache.org/performance/complex_type}SoapPort20
> 003.http-c
> onduit">
> 
>         <http:client ConnectionTimeout="300000"
> ReceiveTimeout="300000"/>
> 
>     </http:conduit>
> 
> </beans>
> 
>  
> 
> 2. Supplied the "cxf-config.xml" file as an argument to the 
> cxf.client.run macro, like 
> jvmarg1="-Dcxf.config.file=wsdl/cxf-config.xml
> 
>  
> 
> Does anyone confirm the way I configured is correct? Is there 
> anyway to find out whether the timeout value that I specified 
> has actually been picked up? It does not seem to be making 
> any difference, even I set reduce the timeout value to 1 ms 
> (my invocation takes about 10 ms).
> 
>  
> 
> Thanks and Regards
> 
> Rao
> 
>