But what if you want a persistent connection?  If you call
releaseConnection() are you not dropping the line? I was assuming that
.recycle() was the correct way to maintain a persistent connection.
Thanks.

-----Original Message-----
From: Kalnichevski, Oleg [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 11, 2004 3:35 AM
To: Commons HttpClient Project
Subject: RE: PostMethod 's recycle method has problem



Himanshu,

Try setting socket timeout to a non-zero value. HttpMethod#recycle among
many things calls HttpMethod#releaseConnection which in its turn
attempts to reads the remaining response content to make sure that
connection reusable. If the socket timeout is not set, releaseConnection
may hang indefinitely under certain circumstances (target server is
slow, congested network, etc)

Besides, I want to echo Odi's comment: there's nothing to be gained from
method recycling. Just create a new HTTP method every time you need to
execute an HTTP request. Do not forget to call
HttpMethod#releaseConnection, though

Oleg

-----Original Message-----
From: Himanshu Thube [mailto:[EMAIL PROTECTED]
Sent: Friday, June 11, 2004 17:52
To: Commons HttpClient Project
Subject: Re: PostMethod 's recycle method has problem


Hi Christopher

Well thats the main problem. When my code comes to asynchPost.recycle()

in code below the program hangs !!

I am giving some code below to give an idea. This is not the original

code though. Does anybody know whats wrong here  ??


while(myflag) {

if(asyncState!=null) {
asynchPost.execute(asyncState,asyncConnection);
} else {
statusCode = asynchHttpsclient.executeMethod(asynchPost);
asyncState=asynchHttpsclient.getState();
}

        if(asynchPost==null) {
            if(usehttps) {
                asynchPost = new PostMethod(httpsasynchUri.toString());
            } else {
                asynchPost = new PostMethod(httpasynchUri.toString());
            }          

        } else if (asynchPost.hasBeenUsed()) {
           asynchPost.recycle();        

        }
        if(deviceProperty.getRequestObject()!=null) {
            Document

request=(Document)deviceProperty.getRequestObject();   

            asynchPost.setRequestBody(new

String(MyUtils.getBytesOfDom(request)));
        }
}
Foran, Christopher wrote:

>I think I know the answer to this one.  You need to call .recycle()
>after every .execute().
>
>-----Original Message-----
>From: Himanshu Thube [mailto:[EMAIL PROTECTED]

>Sent: Thursday, June 10, 2004 10:18 PM
>To: [EMAIL PROTECTED]
>Subject: PostMethod 's recycle method has problem
>
>
>Hi all,
>
>Thanks for all your answers for my questions till now. I have a problem

>with PostMethod. When I reuse the same method it gives a exception that

>PostMethod  needs to be recycled. So I had put a check with help of

>hasbeenUsed() method of PostMethod and trying to recycle the
PostMethod.
>
>Unfortunately my program hangs :( when it reaches recycle() call or
even
>
>if I try to print the ResponseBody of method.
>
>Can someone let me know where could be the problem ??
>
>Just to menthion, I am calling same post method with same request and

>URL in a indefinite while loop until someone sets the while flag to
>false.
>
>- Himanshu
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail:
>[EMAIL PROTECTED]
>For additional commands, e-mail:
>[EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail:
[EMAIL PROTECTED]
>For additional commands, e-mail:
[EMAIL PROTECTED]
>
>
>
> 

>



---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]


************************************************************************
***************************
The information in this email is confidential and may be legally
privileged.  Access to this email by anyone other than the intended
addressee is unauthorized.  If you are not the intended recipient of
this message, any review, disclosure, copying, distribution, retention,
or any action taken or omitted to be taken in reliance on it is
prohibited and may be unlawful.  If you are not the intended recipient,
please reply to or forward a copy of this message to the sender and
delete the message, any attachments, and any copies thereof from your
system.
************************************************************************
***************************

---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to