随笔 - 170  文章 - 536  trackbacks - 0
<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用链接

我参与的团队

随笔分类(103)

搜索

  •  

积分与排名

  • 积分 - 410548
  • 排名 - 134

最新评论

阅读排行榜

  服务器上用 HttpClient 远程调用另一台服务器的一些资源,但是用 netstat 查看经常出现了很多的 CLOSE_WAIT 的连接,最后追查原因,是因为 HttpClient 的 method.releaseConnection() 并不是强制释放连接,为了减小连接数,使用了如下解决方案。在 HttpClient 完成请求后的 finally 块里面这么写。

    } finally {

           if (method != null) {

              try {

                  method.releaseConnection();

              } catch (Exception e) {

                  logger.error("-------> Release HTTP connection exception:", e);

              }

           }

           if (client != null) {

              try {

                  ((SimpleHttpConnectionManager) client.getHttpConnectionManager()).shutdown();

              } catch (Exception e) {

                  logger.error("-------> Close HTTP connection exception:", e);

              }

              client = null;

           }

       }


原文:http://www.steadyxp.com/archives/832.html
posted on 2009-02-23 13:49 steady 阅读(4368) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: