Hi Andrew,

The HTTPURLConnection is retrieved on demand when the invocation is being
prepared. So its not statically associated with the interceptor chain.

However the HTTPConduit does cache the current connection in the
HTTPConduit.KEY_HTTP_CONNECTION
property (i.e. "http.connection") property on the message object, so you
could experiment by writing an interceptor that retrieves the value of this
property and manipulates the connection directly.

Cheers,
Eoghan

On 9 March 2010 12:01, Andrew Clegg <[email protected]> wrote:

>
> Hi,
>
> Given a Dispatch that's been invoked asynchronously (or in another thread,
> manually) -- is it possible to get at the underlying HttpURLConnection that
> it's using?
>
> I can see how you get to the Conduit but then I get a bit stuck.
>
> Here's the reason I'm asking:
>
> I'm having trouble with a misbehaving remote SOAP service that sends
> regular
> XML comments in the response stream while it's 'thinking', i.e.:
>
> <!--...processing-->
>
> ... but sometimes goes wrong and never returns the proper results. This
> means that my client sits waiting and taking up resources for hours.
>
> The httpClientPolicy.setReceiveTimeout() method doesn't help in this case,
> as it sets the read timeout of the connection -- and the javadocs for
> URLConnection say:
>
> "A non-zero value specifies the timeout when reading from Input stream when
> a connection is established to a resource. If the timeout expires before
> there is data available for read, a java.net.SocketTimeoutException is
> raised."
>
> In this particular case, because of the comments sent by the service,
> there's data to read, so the service never times out.
>
> What I'd like to do instead is have a timer that forcibly disconnects after
> a particular timeout. However, it doesn't respond to interrupting the
> thread, so I need to get to the connection, close its streams and
> disconnect. Otherwise, it will just sit there, taking up a thread pool
> slot,
> some memory and a socket, until the service at the other end finally gives
> up. And -- strictly speaking -- I have no guarantee that it ever will.
>
> Any ideas?
>
> Thanks,
>
> Andrew.
>
>
> --
> View this message in context:
> http://old.nabble.com/How-to-get-HttpURLConnection-of-Dispatch-client-tp27834705p27834705.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Reply via email to