Hi Chandru,

If you're running your code from netbeans, make sure there is no proxy
configured there. I've seen this happen before.

Regards
Kiren

On Mon, May 21, 2012 at 5:04 PM, Sergey Beryozkin <[email protected]>wrote:

> On 21/05/12 15:59, Ganesan, Chandru wrote:
>
>> Thanks Sergey. Could you point me to sample test and demo code?
>>
>
> JAXRSClientServerBookTest has in systests/jaxrs (and likely few other
> tests) has few calls getting JSON back, Jackson based test is there.
> I think one of the basic jaxrs demos in the distro does it.
>
> jaxrs_advanced in the Talend TESB distro does it too
>
>
> Cheers, Sergey
>
>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:[email protected]]
>> Sent: Monday, May 21, 2012 4:39 AM
>> To: [email protected]
>> Subject: Re: SocketTimeoutException on POST request using Webclient
>>
>> On 20/05/12 23:48, Ganesan, Chandru wrote:
>>
>>> I did try setting a high timeout value. The problem is the client is
>>> unable to read the response from the server. When I execute the request
>>> from the Firefox client, I get instant response. Is there any special
>>> handling in the client to process the JSON response from a POST request?
>>>
>>
>> I'm not aware of any restrictions that can prevent a JSON payload from
>> being read successfully (meaning - causing a read timeout exception)
>> with WebClient, we have the test and demo code reading JSON.
>>
>> May be you can offer a test case ?
>>
>> Cheers, Sergey
>>
>>>
>>> -----Original Message-----
>>> From: Sergey Beryozkin [mailto:[email protected]]
>>> Sent: Sunday, May 20, 2012 11:12 AM
>>> To: [email protected]
>>> Subject: Re: SocketTimeoutException on POST request using Webclient
>>>
>>> Hi
>>> On 19/05/12 13:50, Ganesan, Chandru wrote:
>>>
>>>> Hi
>>>>
>>>> When I execute  a POST message (JSON) using WebClient the client fails
>>>> with SocketTimeoutException (see exception below).
>>>> The same request works fine from Firefox REST client. I think there a
>>>> problem with how I'm executing the POST from WebClient?
>>>>
>>>>  CXF client code times out after 60 secs or so by default, so it can be
>>> configured from Spring or code, example:
>>> WebClient.getConfig(wc).**getHttpConduit().getClient().**
>>> setReceiveTimeout(6000000);
>>>
>>> HTH, Sergey
>>>
>>>
>>>  Thanks for the help
>>>>
>>>> Sample code:
>>>> ==========
>>>>
>>>>                  ----------------------
>>>>           webClient.reset();
>>>>           webClient.path(serviceList.**get(ASSET) + "/" + id);
>>>>           webClient.type(MediaType.**APPLICATION_JSON);
>>>>           webClient.accept(MediaType.**APPLICATION_JSON);
>>>>
>>>>           Response response = null;
>>>>           try {
>>>>               ObjectMapper mapper = new ObjectMapper();
>>>>               String postMessage = mapper.writeValueAsString(**
>>>> properties);
>>>>               response = webClient.post(postMessage);
>>>>           } catch (Exception e) {
>>>>               throw new ValidationException(e);
>>>>           }
>>>>
>>>>           if (response.getStatus() == Status.OK.getStatusCode()) {
>>>>               return true;
>>>>           }
>>>>           return retVal;
>>>> Here is the server exception:
>>>>
>>>> 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:**243)
>>>>                   at org.apache.cxf.jaxrs.client.**
>>>> WebClient.doChainedInvocation(**WebClient.java:595)
>>>>                   at org.apache.cxf.jaxrs.client.**
>>>> WebClient.doInvoke(WebClient.**java:576)
>>>>                   at org.apache.cxf.jaxrs.client.**
>>>> WebClient.invoke(WebClient.**java:240)
>>>>                   at org.apache.cxf.jaxrs.client.**
>>>> WebClient.post(WebClient.java:**249)
>>>> Caused by: java.net.**SocketTimeoutException: SocketTimeoutException
>>>> invoking http://.......................**..............................
>>>> **.: Read timed out
>>>>                   at 
>>>> sun.reflect.**NativeConstructorAccessorImpl.**newInstance0(Native
>>>> Method)
>>>>                   at sun.reflect.**NativeConstructorAccessorImpl.**
>>>> newInstance(**NativeConstructorAccessorImpl.**java:39)
>>>>                   at sun.reflect.**DelegatingConstructorAccessorI**
>>>> mpl.newInstance(**DelegatingConstructorAccessorI**mpl.java:27)
>>>>                   at java.lang.reflect.Constructor.**
>>>> newInstance(Constructor.java:**513)
>>>>                   at org.apache.cxf.transport.http.**HTTPConduit$**
>>>> WrappedOutputStream.**mapException(HTTPConduit.java:**2058)
>>>>                   at org.apache.cxf.transport.http.**HTTPConduit$**
>>>> WrappedOutputStream.close(**HTTPConduit.java:2043)
>>>>                   at org.apache.cxf.transport.**AbstractConduit.close(*
>>>> *AbstractConduit.java:66)
>>>>                   at org.apache.cxf.transport.http.**
>>>> HTTPConduit.close(HTTPConduit.**java:639)
>>>>                   at org.apache.cxf.interceptor.**
>>>> MessageSenderInterceptor$**MessageSenderEndingInterceptor**
>>>> .handleMessage(**MessageSenderInterceptor.java:**62)
>>>>                   ... 135 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:1195)
>>>>                   at java.net.HttpURLConnection.**getResponseCode(**
>>>> HttpURLConnection.java:379)
>>>>
>>>> Chandru
>>>>
>>>>
>>>
>>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Reply via email to