cerulean

          各種timeout的設置

          HttpClient.getHttpConnectionManager().getParams().setSoTimeout()
          HttpClient.getHttpConnectionManager().getParams().setConnectionTimeout()

          第一個針對連接建立后,但是沒有收到response的超時時間,測試時可將server simulator收到request后等一段時間后再回response。
          出錯信息:
          java.net.SocketTimeoutException: Read timed out

          第二個針對連接建立的超時時間,測試時可將目的IP地址設為不存在的IP地址。
          出錯信息:
          org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 8000 ms
                  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:154)
          默認值為0,如果不設置的話大概2分多鐘才會得到異常


          posted on 2009-09-10 16:09 cerulean 閱讀(5181) 評論(1)  編輯  收藏 所屬分類: Java

          評論

          # re: 各種timeout的設置 2010-08-03 12:16 wuyahuang

          setConnectionTimeout

          public void setConnectionTimeout(int timeout)

          Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default value is zero.

          Parameters:
          timeout - Timeout in milliseconds.

          默認是0,不設置的話就堵住了。永遠出不來了。這是官方的API寫的。你看看  回復  更多評論   

          導航

          <2009年9月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 如皋市| 秦皇岛市| 永川市| 玉溪市| 阜新市| 阿拉善右旗| 临邑县| 库尔勒市| 镇远县| 舟山市| 蓬莱市| 皮山县| 乌拉特后旗| 临泽县| 安庆市| 洞头县| 宁明县| 祥云县| 称多县| 和静县| 绥江县| 温宿县| 桂平市| 县级市| 惠水县| 平邑县| 城口县| 逊克县| 隆林| 宕昌县| 吉安县| 牙克石市| 迁安市| 大渡口区| 长治市| 西和县| 右玉县| 绩溪县| 津市市| 盐亭县| 布尔津县|