You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Chris Geer <ch...@cxtsoftware.com> on 2013/02/02 08:30:16 UTC

WebClient error with long URLs

We have some web services where we use long query strings to access
(encoded JSON). For the most part everything works just fine but for some
of our test cases we are using the CXF WebClient to call those web
services. Just recently we've been getting this type of error (see below).
Through some testing we've determined that the failure only occurs when the
URL is of a certain length. For example on this web service if the URL is
between 361-365 characters or 425-432 characters or 441-443 characters it
will fail with this error. All other url lengths seem to work between
335-484. For the life of me I can't seem to figure out what the problem
would be. At first I thought it was the server but when debugging on the
server the call makes it there and complete just fine without error. If I
turn on debug logging it will say "Socket is not connected" when it tries
to send the response message (see below) for the failed cases so it looks
like the client is closing the connection. As another data point, if I copy
and paste the URL that fails into a browser it loads just fine.

CXF: 2.6.3
Karaf: 2.2.9

I've tried upgrading both our client and server to CXF 2.6.5 & 2.7.2 and
see the same issues.

Feb 2, 2013 12:09:30 AM org.apache.cxf.phase.PhaseInterceptorChain
doDefaultLogging
WARNING: Interceptor for {
http://localhost/services/operations/autodispatchrules/lookup}WebClient has
thrown exception, unwinding now
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:271)
at
org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:581)
at
org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:904)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:772)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:759)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:273)
at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:299)
at CXFClientTest.queryUrl(CXFClientTest.java:35)
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:45)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
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:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.net.SocketException: SocketException invoking
http://localhost/services/operations/autodispatchrules/lookup?search=%7B%22MaxResults%22%3A5%2C%22AdvancedSearchParameters%22%3A%5B%7B%22Values%22%3A%5B%22000000000000000000000000000%22%5D%2C%22Field%22%3A%22Name%22%2C%22Type%22%3A%22string%22%2C%22IncludeNulls%22%3Afalse%2C%22ComparisonOperator%22%3A%22equal_to%22%2C%22WildcardCharacter%22%3A%22*%22%7D%5D%7D:
Unexpected end of file from server
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1336)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1320)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 36 more
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:774)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:771)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at
org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:248)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1515)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1488)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1307)
... 39 more

Server Side Debug

17:18:38,958 | DEBUG | %22*%22%7D%5D%7D | ServletController
 | 146 - org.apache.cxf.cxf-api - 2.6.3 | Finished servicing http request
on thread: Thread[qtp787202333-53 -
/cxf/services/operations/autodispatchrules/lookup?search=%7B%22MaxResults%22%3A5%2C%22AdvancedSearchParameters%22%3A%5B%7B%22Values%22%3A%5B%221234567890123456789012345678901%22%5D%2C%22Field%22%3A%22Name%22%2C%22Type%22%3A%22string%22%2C%22IncludeNulls%22%3Afalse%2C%22ComparisonOperator%22%3A%22equal_to%22%2C%22WildcardCharacter%22%3A%22*%22%7D%5D%7D,5,Configuration
Admin Service]
17:18:38,959 | DEBUG | %22*%22%7D%5D%7D | Server
| 115 - org.eclipse.jetty.util - 7.5.4.v20111024 | RESPONSE
/cxf/services/operations/autodispatchrules/lookup  200
17:18:39,178 | DEBUG | qtp787202333-54  | ChannelEndPoint
 | 115 - org.eclipse.jetty.util - 7.5.4.v20111024 |
java.net.SocketException: Socket is not connected
at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)[:1.6.0_37]
at
sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:665)[:1.6.0_37]
at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:430)[:1.6.0_37]
at
org.eclipse.jetty.io.nio.ChannelEndPoint.shutdownInput(ChannelEndPoint.java:118)[116:org.eclipse.jetty.io:7
.5.4.v20111024]
at
org.eclipse.jetty.io.nio.ChannelEndPoint.fill(ChannelEndPoint.java:198)[116:org.eclipse.jetty.io:7
.5.4.v20111024]
at
org.eclipse.jetty.http.HttpParser.fill(HttpParser.java:949)[117:org.eclipse.jetty.http:7.5.4.v20111024]
at
org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:274)[117:org.eclipse.jetty.http:7.5.4.v20111024]
at
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[117:org.eclipse.jetty.http:7.5.4.v20111024]
at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[121:org.eclipse.jetty.server:7.5.4.v20111024]
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[116:org.eclipse.jetty.io:7
.5.4.v20111024]
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[116:org.eclipse.jetty.io:7
.5.4.v20111024]
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[115:org.eclipse.jetty.util:7.5.4.v20111024]
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[115:org.eclipse.jetty.util:7.5.4.v20111024]
at java.lang.Thread.run(Thread.java:680)[:1.6.0_37]

Any thoughts on what to try to resolve this?

Thanks,
Chris

Re: WebClient error with long URLs

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

I can only assume that Java HTTPURL Connection limits a number of query 
strings, WebClient itself does not enforce it.

Can you try, on 2.7.2, the async client invocation, example,

Future<Book> future = webClient.get(MyInvocationHandler);

This will go via Apache HTTP Client...

thanks, Sergey

On 02/02/13 07:30, Chris Geer wrote:
> We have some web services where we use long query strings to access
> (encoded JSON). For the most part everything works just fine but for some
> of our test cases we are using the CXF WebClient to call those web
> services. Just recently we've been getting this type of error (see below).
> Through some testing we've determined that the failure only occurs when the
> URL is of a certain length. For example on this web service if the URL is
> between 361-365 characters or 425-432 characters or 441-443 characters it
> will fail with this error. All other url lengths seem to work between
> 335-484. For the life of me I can't seem to figure out what the problem
> would be. At first I thought it was the server but when debugging on the
> server the call makes it there and complete just fine without error. If I
> turn on debug logging it will say "Socket is not connected" when it tries
> to send the response message (see below) for the failed cases so it looks
> like the client is closing the connection. As another data point, if I copy
> and paste the URL that fails into a browser it loads just fine.
>
> CXF: 2.6.3
> Karaf: 2.2.9
>
> I've tried upgrading both our client and server to CXF 2.6.5&  2.7.2 and
> see the same issues.
>
> Feb 2, 2013 12:09:30 AM org.apache.cxf.phase.PhaseInterceptorChain
> doDefaultLogging
> WARNING: Interceptor for {
> http://localhost/services/operations/autodispatchrules/lookup}WebClient has
> thrown exception, unwinding now
> 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:271)
> at
> org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:581)
> at
> org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:904)
> at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:772)
> at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:759)
> at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:273)
> at org.apache.cxf.jaxrs.client.WebClient.get(WebClient.java:299)
> at CXFClientTest.queryUrl(CXFClientTest.java:35)
> 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:45)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
> 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:30)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
> 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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Caused by: java.net.SocketException: SocketException invoking
> http://localhost/services/operations/autodispatchrules/lookup?search=%7B%22MaxResults%22%3A5%2C%22AdvancedSearchParameters%22%3A%5B%7B%22Values%22%3A%5B%22000000000000000000000000000%22%5D%2C%22Field%22%3A%22Name%22%2C%22Type%22%3A%22string%22%2C%22IncludeNulls%22%3Afalse%2C%22ComparisonOperator%22%3A%22equal_to%22%2C%22WildcardCharacter%22%3A%22*%22%7D%5D%7D:
> Unexpected end of file from server
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1336)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1320)
> at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
> at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> ... 36 more
> Caused by: java.net.SocketException: Unexpected end of file from server
> at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:774)
> at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
> at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:771)
> at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
> at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
> at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
> at
> org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:248)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1515)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1488)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1307)
> ... 39 more
>
> Server Side Debug
>
> 17:18:38,958 | DEBUG | %22*%22%7D%5D%7D | ServletController
>   | 146 - org.apache.cxf.cxf-api - 2.6.3 | Finished servicing http request
> on thread: Thread[qtp787202333-53 -
> /cxf/services/operations/autodispatchrules/lookup?search=%7B%22MaxResults%22%3A5%2C%22AdvancedSearchParameters%22%3A%5B%7B%22Values%22%3A%5B%221234567890123456789012345678901%22%5D%2C%22Field%22%3A%22Name%22%2C%22Type%22%3A%22string%22%2C%22IncludeNulls%22%3Afalse%2C%22ComparisonOperator%22%3A%22equal_to%22%2C%22WildcardCharacter%22%3A%22*%22%7D%5D%7D,5,Configuration
> Admin Service]
> 17:18:38,959 | DEBUG | %22*%22%7D%5D%7D | Server
> | 115 - org.eclipse.jetty.util - 7.5.4.v20111024 | RESPONSE
> /cxf/services/operations/autodispatchrules/lookup  200
> 17:18:39,178 | DEBUG | qtp787202333-54  | ChannelEndPoint
>   | 115 - org.eclipse.jetty.util - 7.5.4.v20111024 |
> java.net.SocketException: Socket is not connected
> at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)[:1.6.0_37]
> at
> sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:665)[:1.6.0_37]
> at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:430)[:1.6.0_37]
> at
> org.eclipse.jetty.io.nio.ChannelEndPoint.shutdownInput(ChannelEndPoint.java:118)[116:org.eclipse.jetty.io:7
> .5.4.v20111024]
> at
> org.eclipse.jetty.io.nio.ChannelEndPoint.fill(ChannelEndPoint.java:198)[116:org.eclipse.jetty.io:7
> .5.4.v20111024]
> at
> org.eclipse.jetty.http.HttpParser.fill(HttpParser.java:949)[117:org.eclipse.jetty.http:7.5.4.v20111024]
> at
> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:274)[117:org.eclipse.jetty.http:7.5.4.v20111024]
> at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[117:org.eclipse.jetty.http:7.5.4.v20111024]
> at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[121:org.eclipse.jetty.server:7.5.4.v20111024]
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[116:org.eclipse.jetty.io:7
> .5.4.v20111024]
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[116:org.eclipse.jetty.io:7
> .5.4.v20111024]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[115:org.eclipse.jetty.util:7.5.4.v20111024]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[115:org.eclipse.jetty.util:7.5.4.v20111024]
> at java.lang.Thread.run(Thread.java:680)[:1.6.0_37]
>
> Any thoughts on what to try to resolve this?
>
> Thanks,
> Chris
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com