You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Andrew Clegg <an...@gmail.com> on 2008/10/29 15:44:15 UTC

Dispatch clients don't read http:conduit timeout settings... Showstopper?

Hi folks,

Couldn't find any way to make this work via Google, hopefully there is
a way or I'm a bit shafted.

I'm working with services that send fairly large chunks of XML around,
and I'm currently testing the client. I have a mock service using the
Provider interface which just waits for a pre-set interval then
returns some XML.

However, when set the interval to greater than one minute and I invoke
it from a Dispatch object, I get this after 60 seconds:

javax.xml.ws.soap.SOAPFaultException: Could not send Message.
	at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:194)
	at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:124)
	at info.cathdb.funcnet_0_1.impl.MockServiceTest.dispatch(MockServiceTest.java:100)
	at info.cathdb.funcnet_0_1.impl.MockServiceTest.testServiceReturnsAfterTwoMinuteDelay(MockServiceTest.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
	at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:179)
	... 27 more
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:129)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1002)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1937)
	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1865)
	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
	... 29 more

I have the following entry in my cxf.xml, and I know it's being read
because I can cause errors by putting garbage in there:

          <http:conduit id="Mock"
name="{http://cathdb.info/FuncNet_0_1/}MockPort.http-conduit">
          	<http:client ConnectionTimeout="600000" ReceiveTimeout="0" />
          </http:conduit>

According to the docs, ReceiveTimeout=0 should give me an indefinite
wait, but it still bombs after a minute. I also tried setting it
explicitly to 600000 (ten minutes), same result.

I also tried this, having seen something like it on a blog post:

          <http:conduit id="generic" name="*.http-conduit">
          	<http:client ConnectionTimeout="600000" ReceiveTimeout="0" />
          </http:conduit>

No joy. Am I doing something obviously wrong here? I hope so because
otherwise I can't use Dispatch clients at all and will have to rewrite
half my codebase!

Ideally I'd like to set the timeout programmatically, rather than from
a config file, but I can't see anything in the JAX-WS API that lets
you get an equivalent of Client#getConduit() for Dispatch objects.

Any suggestions appreciated!

Thanks once again,

Andrew.

PS CXF version 2.1.2, but I couldn't find any JIRAs suggesting this
was an old fixed issue.

Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Andrew Clegg <an...@gmail.com>.
Ian, do you mean something like this? Sorry, I don't know any Spring...

	<cxf:bus>
		<cxf:features>
			<bean class="info.cathdb.funcnet_0_1.impl.HttpClientConfigFeature" />
		</cxf:features>
	</cxf:bus>

And then:

public class HttpClientConfigFeature extends AbstractFeature
{
    HTTPClientPolicy myConfig;
    public void initialize( Client client, Bus bus )
    {
        myConfig = new HTTPClientPolicy();
        myConfig.setReceiveTimeout( 0 );
        myConfig.setConnectionTimeout( 0 );

        Conduit conduit = client.getConduit();
        if( conduit instanceof HTTPConduit && myConfig != null )
        {
            HTTPConduit httpConduit = ( HTTPConduit ) conduit;
            httpConduit.setClient( myConfig );
        }
        super.initialize( client, bus );
    }
}

That compiles fine but still times out in 1min.

I don't know if it's not working because I haven't configured
something right, or if it's just not possible to add it to the bus
like that...

Andrew.

2008/10/30 Ian Roberts <i....@dcs.shef.ac.uk>:
> Andrew Clegg wrote:
>> Hi Willem,
>>
>> Thanks for confirmation, I'll do a little example case and raise a
>> JIRA when I get a chance.
>>
>> Regarding this workaround, is there a way to make this work for *all*
>> conduits, like the <http-conf:conduit name="*.http-conduit"> approach,
>> or do I have to configure it separately for every endpoint?
>
> Try adding the feature to the bus instead of the client?
>
> Ian
>
> --
> Ian Roberts               | Department of Computer Science
> i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK
>

Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
Andrew Clegg wrote:
> Hi Willem,
> 
> Thanks for confirmation, I'll do a little example case and raise a
> JIRA when I get a chance.
> 
> Regarding this workaround, is there a way to make this work for *all*
> conduits, like the <http-conf:conduit name="*.http-conduit"> approach,
> or do I have to configure it separately for every endpoint?

Try adding the feature to the bus instead of the client?

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK

Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Andrew Clegg <an...@gmail.com>.
Hi Willem,

Thanks for confirmation, I'll do a little example case and raise a
JIRA when I get a chance.

Regarding this workaround, is there a way to make this work for *all*
conduits, like the <http-conf:conduit name="*.http-conduit"> approach,
or do I have to configure it separately for every endpoint?

Cheers,

Andrew.

2008/10/30 Willem Jiang <wi...@gmail.com>:
> Hi Andrew,
>
> I think it could be a CXF bug.
> Here is a way to set the ClientPolicy into the dispatch by writing a
> custom Feature.
>
> public class HttpClientConfigFeature extends AbstractFeature {
> HttpClientPolicy myConfig;
>
> @Override
> public void initialize(Client client, Bus bus) {
> Conduit conduit = client.getConduit();
>  if (conduit instanceof HttpConduit && myConfig != null) {
>    HttpConduit httpConduit = (HttpConduit)conduit;
>    httpConduit.setClient(myConfig);
>  }
>  super.initialize(client, bus);
> }
> ...
> }
>
> You need to configure this feature into with below configuration
>
> <client id="MockClient" xmlns="http://cxf.apache.org/jaxws"
>        xmlns:ns="http://cathdb.info/FuncNet_0_1/"
>        serviceName="ns:XXXService"
>        endpointName="ns:MockPort"
>        wsdlLocation="wsdl/hello_world.wsdl"
>        address=YOUR_ADDESS
>        serviceClass=DUMMYCLASS >
> <features>
> <bean xmlns="http://www.springframework.org/schema/beans"
> class="HttpClientConfigFeature">
> <property name="myConfig" ref="refConfig">
> </property>
> </bean>
> </features>
> </client>
>
> Willem
>
> Andrew Clegg wrote:
>> Unfortunately not -- it still times out after 60s during the get()
>> call, presumably since it's still using the same underlying transport.
>>
>> Actually server-side asynchronous operations are on my to-do list for
>> the future, so showstopper was perhaps a bit of an exaggeration. But
>> I'm trying to get some load tests passing before this weekend for a
>> release, and async ops certainly won't happen by then...
>>
>> Also, I just discovered a workaround -- specifying the timeout in the
>> WSDL does work for my dispatch objects:
>>
>>       <wsdl:service name="MockService">
>>               <wsdl:port binding="tns:MockBinding" name="MockPort">
>>                       <soap:address location="http://localhost:9001/Mock" />
>>                       <http-conf:client ReceiveTimeout="0" />
>>               </wsdl:port>
>>       </wsdl:service>
>>
>> Even though the identical element in cxf.xml doesn't:
>>
>>           <http-conf:conduit id="Mock"
>> name="{http://cathdb.info/FuncNet_0_1/}MockPort.http-conduit">
>>               <http-conf:client ReceiveTimeout="0" />
>>           </http-conf:conduit>
>>
>> http-conf refers to
>> http://cxf.apache.org/transports/http/configuration both times.
>>
>> Not ideal, because I can't do this for other people's services without
>> downloading their WSDLs and modifying them. If any of the dev team
>> read this and confirm that it's a bug, and not pilot error, let me
>> know and I'll log a JIRA with a test case.
>>
>> Or if there is some arcane way of modifying the ClientPolicy for a
>> Dispatch, then please let me know, as this would be my preferred
>> approach.
>>
>> Cheers,
>>
>> Andrew.
>>
>>
>> 2008/10/29 Glen Mazza <gl...@gmail.com>:
>>> Pardon the non-answer, but perhaps using an async client (either Dispatch or
>>> JAX-WS based) may be the solution for what you need anyway.  Check the first
>>> paragraph of here:  http://www.jroller.com/gmazza/date/20080308
>>>
>>> HTH,
>>> Glen
>>>
>>>
>>> Andrew Clegg wrote:
>>>> I'm working with services that send fairly large chunks of XML around,
>>>> and I'm currently testing the client. I have a mock service using the
>>>> Provider interface which just waits for a pre-set interval then
>>>> returns some XML.
>>>>
>>> --
>>> View this message in context: http://www.nabble.com/Dispatch-clients-don%27t-read-http%3Aconduit-timeout-settings...-Showstopper--tp20228606p20230670.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>
>
>

Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Andrew,

I think it could be a CXF bug.
Here is a way to set the ClientPolicy into the dispatch by writing a
custom Feature.

public class HttpClientConfigFeature extends AbstractFeature {
HttpClientPolicy myConfig;

@Override
public void initialize(Client client, Bus bus) {
Conduit conduit = client.getConduit();
  if (conduit instanceof HttpConduit && myConfig != null) {
    HttpConduit httpConduit = (HttpConduit)conduit;
    httpConduit.setClient(myConfig);
  }
  super.initialize(client, bus);
}
...
}

You need to configure this feature into with below configuration

<client id="MockClient" xmlns="http://cxf.apache.org/jaxws"
	xmlns:ns="http://cathdb.info/FuncNet_0_1/"
	serviceName="ns:XXXService"
	endpointName="ns:MockPort"
        wsdlLocation="wsdl/hello_world.wsdl"
	address=YOUR_ADDESS
	serviceClass=DUMMYCLASS >
<features>
<bean xmlns="http://www.springframework.org/schema/beans"
class="HttpClientConfigFeature">
<property name="myConfig" ref="refConfig">
</property>
</bean>
</features>
</client>

Willem

Andrew Clegg wrote:
> Unfortunately not -- it still times out after 60s during the get()
> call, presumably since it's still using the same underlying transport.
> 
> Actually server-side asynchronous operations are on my to-do list for
> the future, so showstopper was perhaps a bit of an exaggeration. But
> I'm trying to get some load tests passing before this weekend for a
> release, and async ops certainly won't happen by then...
> 
> Also, I just discovered a workaround -- specifying the timeout in the
> WSDL does work for my dispatch objects:
> 
> 	<wsdl:service name="MockService">
> 		<wsdl:port binding="tns:MockBinding" name="MockPort">
> 			<soap:address location="http://localhost:9001/Mock" />
> 			<http-conf:client ReceiveTimeout="0" />
> 		</wsdl:port>
> 	</wsdl:service>
> 
> Even though the identical element in cxf.xml doesn't:
> 
>           <http-conf:conduit id="Mock"
> name="{http://cathdb.info/FuncNet_0_1/}MockPort.http-conduit">
>           	<http-conf:client ReceiveTimeout="0" />
>           </http-conf:conduit>
> 
> http-conf refers to
> http://cxf.apache.org/transports/http/configuration both times.
> 
> Not ideal, because I can't do this for other people's services without
> downloading their WSDLs and modifying them. If any of the dev team
> read this and confirm that it's a bug, and not pilot error, let me
> know and I'll log a JIRA with a test case.
> 
> Or if there is some arcane way of modifying the ClientPolicy for a
> Dispatch, then please let me know, as this would be my preferred
> approach.
> 
> Cheers,
> 
> Andrew.
> 
> 
> 2008/10/29 Glen Mazza <gl...@gmail.com>:
>> Pardon the non-answer, but perhaps using an async client (either Dispatch or
>> JAX-WS based) may be the solution for what you need anyway.  Check the first
>> paragraph of here:  http://www.jroller.com/gmazza/date/20080308
>>
>> HTH,
>> Glen
>>
>>
>> Andrew Clegg wrote:
>>> I'm working with services that send fairly large chunks of XML around,
>>> and I'm currently testing the client. I have a mock service using the
>>> Provider interface which just waits for a pre-set interval then
>>> returns some XML.
>>>
>> --
>> View this message in context: http://www.nabble.com/Dispatch-clients-don%27t-read-http%3Aconduit-timeout-settings...-Showstopper--tp20228606p20230670.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
> 


Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Andrew Clegg <an...@gmail.com>.
Unfortunately not -- it still times out after 60s during the get()
call, presumably since it's still using the same underlying transport.

Actually server-side asynchronous operations are on my to-do list for
the future, so showstopper was perhaps a bit of an exaggeration. But
I'm trying to get some load tests passing before this weekend for a
release, and async ops certainly won't happen by then...

Also, I just discovered a workaround -- specifying the timeout in the
WSDL does work for my dispatch objects:

	<wsdl:service name="MockService">
		<wsdl:port binding="tns:MockBinding" name="MockPort">
			<soap:address location="http://localhost:9001/Mock" />
			<http-conf:client ReceiveTimeout="0" />
		</wsdl:port>
	</wsdl:service>

Even though the identical element in cxf.xml doesn't:

          <http-conf:conduit id="Mock"
name="{http://cathdb.info/FuncNet_0_1/}MockPort.http-conduit">
          	<http-conf:client ReceiveTimeout="0" />
          </http-conf:conduit>

http-conf refers to
http://cxf.apache.org/transports/http/configuration both times.

Not ideal, because I can't do this for other people's services without
downloading their WSDLs and modifying them. If any of the dev team
read this and confirm that it's a bug, and not pilot error, let me
know and I'll log a JIRA with a test case.

Or if there is some arcane way of modifying the ClientPolicy for a
Dispatch, then please let me know, as this would be my preferred
approach.

Cheers,

Andrew.


2008/10/29 Glen Mazza <gl...@gmail.com>:
>
> Pardon the non-answer, but perhaps using an async client (either Dispatch or
> JAX-WS based) may be the solution for what you need anyway.  Check the first
> paragraph of here:  http://www.jroller.com/gmazza/date/20080308
>
> HTH,
> Glen
>
>
> Andrew Clegg wrote:
>>
>> I'm working with services that send fairly large chunks of XML around,
>> and I'm currently testing the client. I have a mock service using the
>> Provider interface which just waits for a pre-set interval then
>> returns some XML.
>>
>
> --
> View this message in context: http://www.nabble.com/Dispatch-clients-don%27t-read-http%3Aconduit-timeout-settings...-Showstopper--tp20228606p20230670.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: Dispatch clients don't read http:conduit timeout settings... Showstopper?

Posted by Glen Mazza <gl...@gmail.com>.
Pardon the non-answer, but perhaps using an async client (either Dispatch or
JAX-WS based) may be the solution for what you need anyway.  Check the first
paragraph of here:  http://www.jroller.com/gmazza/date/20080308

HTH,
Glen


Andrew Clegg wrote:
> 
> I'm working with services that send fairly large chunks of XML around,
> and I'm currently testing the client. I have a mock service using the
> Provider interface which just waits for a pre-set interval then
> returns some XML.
> 

-- 
View this message in context: http://www.nabble.com/Dispatch-clients-don%27t-read-http%3Aconduit-timeout-settings...-Showstopper--tp20228606p20230670.html
Sent from the cxf-user mailing list archive at Nabble.com.