Three timeout settings in httpClient in Java

Source: Internet
Author: User

Three timeout settings in httpClient in Java
This article introduces three timeout settings in httpClient in Java.

In the HttpClient package of Apache, there are three timeout settings:

/* Obtain the connection timeout value from the connection pool */ConnManagerParams. setTimeout (params, 1000);/* connection timeout */HttpConnectionParams. setConnectionTimeout (params, 2000);/* request timeout */HttpConnectionParams. setSoTimeout (params, 4000 );
First, ConnectionPoolTimeout:
Defines the timeout time for retrieving connections from the connection pool managed by ConnectionManager.
ConnectionPoolTimeoutException is thrown when an error occurs.

Second, ConnectionTimeout:
Defines the timeout time for establishing a connection with the server through the network. The Httpclient Package creates a socket connection with the server through an asynchronous thread, which is the timeout time for the socket connection.
When an error occurs while connecting to the HTTP server or waiting for a valid connection to be managed by HttpConnectionManager, ConnectionTimeoutException is thrown.

Third, SocketTimeout:
This defines the timeout time for Socket Data Reading, that is, the time needed to wait for the response data to be obtained from the server.
When the read or receive Socket times out, SocketTimeoutException is thrown.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.