Three time-out settings in HttpClient

Source: Internet
Author: User

In Apache's httpclient package, there are three settings where the setting expires:


(1)/* Timeout for the connection from the socket connection pool */[Socket connection pool]
Connmanagerparams.settimeout (params, 1000);


Set Connectionpooltimeout:

This defines the timeout for removing the connection from the ConnectionManager managed connection pool, set here to 1 seconds.



(2)/* Connection timeout time for socket connection to server */
Httpconnectionparams.setconnectiontimeout (params, 2000);

Set ConnectionTimeout:

This defines the time-out for establishing a socket connection to the server over a network. HttpClient package to create a socket connection to the server, which is the time-out of the socket connection, set here to 2 seconds.



(3)/*socket timeout time to read data */"Response timeout"
Httpconnectionparams.setsotimeout (params, 4000);

Set Sockettimeout

This defines the time-out for the socket read data, that is, how long it will take for the response data to be fetched from the server, set here to 4 seconds.



Each of the above 3 timeouts will throw connectionpooltimeoutexception,

Connectiontimeoutexception

Sockettimeoutexception.


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.