On Fri, 2006-09-15 at 08:49 -0400, Mark Claassen wrote: > I have been using the HttpClient for a while now and really like it. > However, I noticed the other day that I was doing the pooling incorrectly. > I was working on it when I got a bit confused. > > Since I was used to using the java.net.* stuff, I took that approach and got > an HttpConnection from the connection manager. Once I got the connection, I > made the transaction and then released the connection. The algorithm I was > using was basically like this: > > connection = > httpClient.getHttpConnectionManager().getConnectionWithTimeout(httpClient.ge > tHostConfiguration(),30000); > post = new PostMethod(...) > post.execute(httpClient.getState(),connection); > ... > connection.releaseConnection(); > > However, this didn't really work at all. My application would just hang for > long periods and then I would get socket errors. Since then I switched to > using the same algorithm as in the examples and everything works great. > > post = new PostMethod() > httpClient.executeMethod(post); > post.releaseConnection(); > > Was there something wrong with getting the connection first?
Mark, There's nothing wrong with acquiring a connection from the connection manager. The trouble is that a lot of HTTP protocol logic is encapsulated in the HttpClient class and is not executed if one is using HttpConnection directly. > Also, is the HttpConnectionManagerParams.setConnectionTimeout(xxx) the same > as HttpConnecitonManager.getConnectionWithTimeout(xxx)? > Not really. The first timeout value determines the maximum connect time (how long HttpClient can spend blocked waiting for a new connection to be established). The latter value is the time HttpClient can spend blocked waiting for an _existing_ connection to be acquired from the pool Hope this helps Oleg > Thanks, > Mark > > > --------------------------------------------------------------------- > 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]
