After turning on logging, the total issued in this message keeps growing and
growing:

org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking[FINE|feed-processor-16|21:46:47]:
[HttpRoute[{}->http://img.ffffound.com]] total kept alive: 240, total
issued: *160*, total allocated: 400 out of 400

Today it started at 100 and is now 160. the day before it started at 30 and
ended at 100.

There is actually one more method I use httpclient within, it is a little
more complex but still very similar to my other code in its usage of
httpclient. It is below.

   public String fetch(String publicUrl, int timeoutMillis, Cookie[]
cookies, Map<String, ?> postData, Map<String, String> headers)
throwsIOException, HttpException

{

    HttpRequestBase method;

    if(postData == null)

        method = new HttpGet(publicUrl);

    else

    {

        HttpPost post = new HttpPost(publicUrl);

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();

        for(Map.Entry<String, ?> entry : postData.entrySet())

        {

            if(entry.getValue() instanceof Collection<?>)

            {

                Collection<?> value = (Collection<?>) entry.getValue();

                for(Object v : value)

                {

                    nvps.add(new BasicNameValuePair(entry.getKey(),
v.toString()));

                }

            }

            else

                nvps.add(new BasicNameValuePair(entry.getKey(),
entry.getValue().toString()));

        }


        post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

        method = post;

    }


    configureMethod(method, timeoutMillis); //sets timeouts, user agent, etc



    if(headers != null)

    {

        for(Map.Entry<String, String> entry : headers.entrySet())

            method.addHeader(entry.getKey(), entry.getValue());

    }



    HttpContext localContext = null;

    if(cookies != null)

    {

        CookieStore cookieStore = new BasicCookieStore();

        for(Cookie c : cookies)

            cookieStore.addCookie(c);



        localContext = new BasicHttpContext();

        localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    }

    HttpResponse resp = null;

    try

    {

        resp = _httpClient.execute(method, localContext);

    }

    catch(Exception ex)

    {

        ex.printStackTrace();

    }

    int statusCode = resp.getStatusLine().getStatusCode();


    if (statusCode != 200)

    {

        if(resp.getEntity() != null)

        {

            try

            {

                EntityUtils.consume(resp.getEntity());

            }

            catch(Exception ex) {} //dropped

        }



        throw new HttpException(statusCode, statusCode + " " + publicUrl + "
failed: " + resp.getStatusLine());

    }

    return EntityUtils.toString(resp.getEntity());

}

On Mon, May 30, 2011 at 4:23 AM, Oleg Kalnichevski <[email protected]> wrote:

> On Mon, 2011-05-30 at 01:00 -0400, feedly team wrote:
> > My application is leaking connections somehow, it runs fine for days
> > continually doing requests but then at some point timeout connections
> start
> > to occur continuously. I am using the ThreadSafeClientConnManager to do
> > requests. I execute http client to do a head request and to get a
> response.
> > The code is below. Are there any problems with it?
>
> I see nothing wrong with your code.
>
>
> > What would be the best
> > logging options to enable to debug leaks?
>
> See 'Enable context logging for connection management / request
> execution' section
>
> http://hc.apache.org/httpcomponents-client-ga/logging.html
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to