XmlRpcSunHttpTransport and read timeout

View: New views
10 Messages — Rating Filter:   Alert me  

XmlRpcSunHttpTransport and read timeout

by Lars Gramark :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The reply timeout set in the XmlRpcHttpClientConfig is ignored when making synchronous calls from the client.
This may cause calls to hang forever if there is no response.

Digging into the code, I noticed that the read timeout provided by the XmlRpcHttpClientConfig
is ignored when creating a URLConnection from the
XmlRpcSunHttpTransport. The method URLConnection.setReadTimeout, made available in Java 1.5, could be used to solve this.
Is this a bug or is it a deliberate choice you've made to keep Java 1.4 compatibility?

Thanks
Lars Gråmark


Re: XmlRpcSunHttpTransport and read timeout

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You're the first one to point this out. Compatibility to 1.4 is not a
problem, because we already have JDK specific variants of the
transports. Wanna provide a patch?


On Tue, Sep 8, 2009 at 3:39 PM, Lars Gramark<lars@...> wrote:

> The reply timeout set in the XmlRpcHttpClientConfig is ignored when making synchronous calls from the client.
> This may cause calls to hang forever if there is no response.
>
> Digging into the code, I noticed that the read timeout provided by the XmlRpcHttpClientConfig
> is ignored when creating a URLConnection from the
> XmlRpcSunHttpTransport. The method URLConnection.setReadTimeout, made available in Java 1.5, could be used to solve this.
> Is this a bug or is it a deliberate choice you've made to keep Java 1.4 compatibility?
>
> Thanks
> Lars Gråmark
>
>



--
Germanys national anthem is the most boring in the world - how telling!

RE: XmlRpcSunHttpTransport and read timeout

by Lars Gramark :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sure. I'll be happy to provide a patch. I'll get back to you.



----- Original Message -----
From: Jochen Wiedmann <jochen.wiedmann@...>
Sent: Tue, 2009/9/8 15:51
To: xmlrpc-dev@...
Subject: Re: XmlRpcSunHttpTransport and read timeout

You're the first one to point this out. Compatibility to 1.4 is not a
problem, because we already have JDK specific variants of the
transports. Wanna provide a patch?


On Tue, Sep 8, 2009 at 3:39 PM, Lars Gramark<lars@...> wrote:

> The reply timeout set in the XmlRpcHttpClientConfig is ignored when making synchronous calls from the client.
> This may cause calls to hang forever if there is no response.
>
> Digging into the code, I noticed that the read timeout provided by the XmlRpcHttpClientConfig
> is ignored when creating a URLConnection from the
> XmlRpcSunHttpTransport. The method URLConnection.setReadTimeout, made available in Java 1.5, could be used to solve this.
> Is this a bug or is it a deliberate choice you've made to keep Java 1.4 compatibility?
>
> Thanks
> Lars Gråmark
>
>



--
Germanys national anthem is the most boring in the world - how telling!

Re: XmlRpcSunHttpTransport and read timeout

by Gam :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
I did rose the issue in feb 2008, providing a fix for this, see here:
http://marc.info/?l=xmlrpc-dev&m=120318156313794&w=2

but my problem was how to make sure we are not on 1.4?

Regards,
Gam.

On 8 sept. 09, at 21:51, Jochen Wiedmann wrote:

> You're the first one to point this out. Compatibility to 1.4 is not a
> problem, because we already have JDK specific variants of the
> transports. Wanna provide a patch?
>
>
> On Tue, Sep 8, 2009 at 3:39 PM, Lars Gramark<lars@...> wrote:
>> The reply timeout set in the XmlRpcHttpClientConfig is ignored when  
>> making synchronous calls from the client.
>> This may cause calls to hang forever if there is no response.
>>
>> Digging into the code, I noticed that the read timeout provided by  
>> the XmlRpcHttpClientConfig
>> is ignored when creating a URLConnection from the
>> XmlRpcSunHttpTransport. The method URLConnection.setReadTimeout,  
>> made available in Java 1.5, could be used to solve this.
>> Is this a bug or is it a deliberate choice you've made to keep Java  
>> 1.4 compatibility?
>>
>> Thanks
>> Lars Gråmark
>>
>>
>
>
>
> --
> Germanys national anthem is the most boring in the world - how  
> telling!


Re: XmlRpcSunHttpTransport and read timeout

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try adding the following method to the XmlRpcSun15HttpTransport and
let me know, whether that works.

Jochen

    protected void initHttpHeaders(XmlRpcRequest pRequest)
            throws XmlRpcClientException {
        final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig)
pRequest.getConfig();
        int connectionTimeout = config.getConnectionTimeout();
        if (connectionTimeout > 0) {
            getURLConnection().setConnectTimeout(connectionTimeout);
        }
        int replyTimeout = config.getReplyTimeout();
        if (replyTimeout > 0) {
            getURLConnection().setReadTimeout(replyTimeout);
        }
        super.initHttpHeaders(pRequest);
    }



--
Germanys national anthem is the most boring in the world - how telling!

Parent Message unknown RE: XmlRpcSunHttpTransport and read timeout

by Lars Gramark :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Works like a charm. I've verified reply timeout and connection timeout.

I guess I made a wrong assumption when pointing out the error in
XmlRpcSunHttpTransport instead of XmlRpcSun15HttpTransport.
The reason was that I used an older version of XMLRPC where the XmlRpcSun15HttpTransport hadn't been introduced yet and
when I looked in the subversion repository, the timeout wasn't corrected in the XmlRpcSunHttpTransport class.
I suppose the patch should be placed in the Java 1.5 specific class as you point out.

Best regards
Lars Gråmark

----- Original Message -----
From: Jochen Wiedmann <jochen.wiedmann@...>
Sent: Wed, 2009/9/9 10:58
To: xmlrpc-dev@...
Subject: Re: XmlRpcSunHttpTransport and read timeout

Try adding the following method to the XmlRpcSun15HttpTransport and
let me know, whether that works.

Jochen

    protected void initHttpHeaders(XmlRpcRequest pRequest)
            throws XmlRpcClientException {
        final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig)
pRequest.getConfig();
        int connectionTimeout = config.getConnectionTimeout();
        if (connectionTimeout > 0) {
            getURLConnection().setConnectTimeout(connectionTimeout);
        }
        int replyTimeout = config.getReplyTimeout();
        if (replyTimeout > 0) {
            getURLConnection().setReadTimeout(replyTimeout);
        }
        super.initHttpHeaders(pRequest);
    }



--
Germanys national anthem is the most boring in the world - how telling!

Re: XmlRpcSunHttpTransport and read timeout

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, commited.

On Thu, Sep 10, 2009 at 12:19 PM, Lars Gramark <lars@...> wrote:
> Works like a charm. I've verified reply timeout and connection timeout.



--
Germanys national anthem is the most boring in the world - how telling!

Re: XmlRpcSunHttpTransport and read timeout

by Gam :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Jochen,

I see that this class is specifically for Java 1.5. Do you know were  
is the code that selects the correct class at runtime? I'm very  
interested to know how it work.

Regards,
Gam.

On 9 sept. 09, at 16:58, Jochen Wiedmann wrote:

> Try adding the following method to the XmlRpcSun15HttpTransport and
> let me know, whether that works.
>
> Jochen
>
>    protected void initHttpHeaders(XmlRpcRequest pRequest)
>            throws XmlRpcClientException {
>        final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig)
> pRequest.getConfig();
>        int connectionTimeout = config.getConnectionTimeout();
>        if (connectionTimeout > 0) {
>            getURLConnection().setConnectTimeout(connectionTimeout);
>        }
>        int replyTimeout = config.getReplyTimeout();
>        if (replyTimeout > 0) {
>            getURLConnection().setReadTimeout(replyTimeout);
>        }
>        super.initHttpHeaders(pRequest);
>    }
>
>
>
> --
> Germanys national anthem is the most boring in the world - how  
> telling!


Re: XmlRpcSunHttpTransport and read timeout

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 11, 2009 at 6:46 AM, Gam <gamaliel@...> wrote:

> I see that this class is specifically for Java 1.5. Do you know were is the
> code that selects the correct class at runtime? I'm very interested to know
> how it work.

See

https://svn.apache.org/viewvc/webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientDefaults.java?view=markup


--
Germanys national anthem is the most boring in the world - how telling!

Re: XmlRpcSunHttpTransport and read timeout

by Gam :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Jochen.
Interesting way of doing it. I was expecting complex class loader  
gymnastic!

Regards,
Gam.

On 11 sept. 09, at 20:43, Jochen Wiedmann wrote:

> On Fri, Sep 11, 2009 at 6:46 AM, Gam <gamaliel@...> wrote:
>
>> I see that this class is specifically for Java 1.5. Do you know  
>> were is the
>> code that selects the correct class at runtime? I'm very interested  
>> to know
>> how it work.
>
> See
>
> https://svn.apache.org/viewvc/webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientDefaults.java?view=markup
>
>
> --
> Germanys national anthem is the most boring in the world - how  
> telling!