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

          常用鏈接

          我參與的團(tuán)隊(duì)

          隨筆分類(103)

          搜索

          •  

          積分與排名

          • 積分 - 414989
          • 排名 - 135

          最新評(píng)論

          閱讀排行榜

            服務(wù)器上用 HttpClient 遠(yuǎn)程調(diào)用另一臺(tái)服務(wù)器的一些資源,但是用 netstat 查看經(jīng)常出現(xiàn)了很多的 CLOSE_WAIT 的連接,最后追查原因,是因?yàn)?HttpClient 的 method.releaseConnection() 并不是強(qiáng)制釋放連接,為了減小連接數(shù),使用了如下解決方案。在 HttpClient 完成請(qǐng)求后的 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 閱讀(4404) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 邻水| 昌乐县| 民丰县| 蓬安县| 周口市| 赤峰市| 郧西县| 浦北县| 南江县| 双辽市| 云霄县| 东山县| 金华市| 姜堰市| 偃师市| 安远县| 安福县| 汪清县| 阿巴嘎旗| 鸡泽县| 达尔| 渝北区| 周口市| 左权县| 北川| 咸宁市| 杭州市| 新和县| 利津县| 酒泉市| 龙南县| 龙陵县| 太原市| 巩义市| 镇巴县| 伊通| 蛟河市| 青冈县| 五莲县| 宾阳县| 海口市|