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

          常用鏈接

          我參與的團隊

          隨筆分類(103)

          搜索

          •  

          積分與排名

          • 積分 - 415096
          • 排名 - 135

          最新評論

          閱讀排行榜

            服務器上用 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 閱讀(4406) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 松溪县| 沾化县| 淳安县| 布拖县| 通江县| 忻州市| 玉龙| 德清县| 内丘县| 晋江市| 武川县| 上虞市| 开平市| 周口市| 沅江市| 巫山县| 贞丰县| 牟定县| 蓝山县| 沂水县| 滕州市| 抚顺县| 朝阳区| 红河县| 利辛县| 高清| 乐至县| 华安县| 吴堡县| 象山县| 江津市| 扎赉特旗| 平乡县| 沂南县| 西乡县| 汤原县| 老河口市| 襄垣县| 永泰县| 永兴县| 雷波县|