hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Dzhurinsky <jdeve...@gmail.com>
Subject "Connection already open" exception in HttpClient 4.2.5
Date Thu, 19 Sep 2013 12:29:41 GMT
Hello! I am facing some strange problem with HttpClient 4.2.5

Here is some Scala code:

  val cm = new PoolingClientConnectionManager()
  cm.setMaxTotal(100)

  val client = new DefaultHttpClient(cm)

  val params = client.getParams

  params.setParameter("http.socket.timeout", 10000)
  params.setParameter("http.tcp.nodelay", true)
  params.setParameter("http.connection.timeout", 10000)
  params.setParameter("http.connection.stalecheck", false)

  client.setHttpRequestRetryHandler(new HttpRequestRetryHandler {
    def retryRequest(exception: IOException, executionCount: Int, context: HttpContext): Boolean
= executionCount < 2
  })

  def processUrl(url: Record) = {
    var req: HttpGet = null
    try {
      req = new HttpGet(url.toString)
      val response = client.execute(req)
      val statusLine = response.getStatusLine
      .....
    } catch {
      case e: Exception =>
        LOG.error("Exception processing task", e)
    }
    finally {
      if (req != null) {
        req.abort()
        req.releaseConnection()
      }
    }
  }


I hope that it's clear what's going on above - I create instance of
PoolingClientConnectionManager, set total pool size to 100, then I do create
client instance and download content of url in method "processUrl".

Sometimes when application uses 30 threads to call processUrl, I can see the
error "Connection already open". I've seen the thread about similar issue back
at 2010, but it looks like fixed, and I am not using any IdleConnectionManager here.

Please advice.

Thanks!

-- 
Eugene N Dzhurinsky

Mime
View raw message