Default timeout for HttpComponent Client

后端 未结 5 656
我寻月下人不归
我寻月下人不归 2021-02-12 17:57

I can\'t find any documentation on the default httpParams for httpclient 4.1 ?

What\'s the default socket timeout when I do a GET ?

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-12 18:53

    For Apache HttpClient version 4.x upwards

    int timeout = 5*60; // seconds (5 minutes)
    RequestConfig config = RequestConfig.custom()
          .setConnectTimeout(timeout * 1000)
          .setConnectionRequestTimeout(timeout * 1000)
          .setSocketTimeout(timeout * 1000).build();
    HttpClient httpClient = 
       HttpClientBuilder.create().setDefaultRequestConfig(config).build();
    

提交回复
热议问题