You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Qiang Zhou <ge...@gmail.com> on 2006/05/12 06:20:15 UTC
Connection is not open
Dear All:
When i invoke releaseConnection method at end program. But system throw
an java.lang.IllegaStateException: Connection is not open!!! What's the
matter with me.
Re: Connection is not open
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2006-05-14 at 21:54 +0800, Qiang Zhou wrote:
> Hello:
> At end of program mean after client.executeMehtod() and
> getResponseStream() method. Not the realy last line in my whole program. For
> example:
> GetMethod method = new GetMethod(http://www.apache.org);
> Httpclient client =new Httpclient();
> try {
> client.executeMethod(method);
> // Read repsone content.
> ...Follow the redirect When response.statusCode=302
> }
> catch(Exception e) {
> }
> finally {
> if(method!=null)
> method.releaseConnection();
> }
>
Qiang,
You are not calling this code from multiple threads, are you? Please
note HttpClient is thread safe only when used with a thread safe
connection manager such MultiThreadedHttpConnectionManager. The simple
connection manager used per default is NOT thread safe.
Oleg
>
> 2006/5/12, Roland Weber <ht...@dubioso.net>:
> >
> > Hello,
> >
> > > When i invoke releaseConnection method at end program. But system
> > throw
> > > an java.lang.IllegaStateException: Connection is not open!!!
> >
> > Do not release the connection at the end of the program.
> > Release the connection after each request you execute,
> > as shown in the tutorial.
> >
> > http://jakarta.apache.org/commons/httpclient/tutorial.html
> >
> > cheers,
> > Roland
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Connection is not open
Posted by Qiang Zhou <ge...@gmail.com>.
Hello:
At end of program mean after client.executeMehtod() and
getResponseStream() method. Not the realy last line in my whole program. For
example:
GetMethod method = new GetMethod(http://www.apache.org);
Httpclient client =new Httpclient();
try {
client.executeMethod(method);
// Read repsone content.
...Follow the redirect When response.statusCode=302
}
catch(Exception e) {
}
finally {
if(method!=null)
method.releaseConnection();
}
2006/5/12, Roland Weber <ht...@dubioso.net>:
>
> Hello,
>
> > When i invoke releaseConnection method at end program. But system
> throw
> > an java.lang.IllegaStateException: Connection is not open!!!
>
> Do not release the connection at the end of the program.
> Release the connection after each request you execute,
> as shown in the tutorial.
>
> http://jakarta.apache.org/commons/httpclient/tutorial.html
>
> cheers,
> Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
Re: Connection is not open
Posted by Roland Weber <ht...@dubioso.net>.
Hello,
> When i invoke releaseConnection method at end program. But system throw
> an java.lang.IllegaStateException: Connection is not open!!!
Do not release the connection at the end of the program.
Release the connection after each request you execute,
as shown in the tutorial.
http://jakarta.apache.org/commons/httpclient/tutorial.html
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org