setConnectTimeout
setConnectTimeout is a method used to specify the maximum time, in milliseconds, allowed to establish a connection to a remote host. It is commonly found in networking APIs such as Java’s HttpURLConnection and related HTTP client libraries, and serves as a safeguard against long hangs when a server is unreachable or network conditions are poor.
The timeout applies to the initial connection attempt. It does not govern data transfer once the connection
If the connection cannot be established within the specified time, the operation will fail with a timeout
Here, the client will wait up to 5 seconds to establish the connection, and up to 10
Related concepts include read timeout (how long to wait for data to be available after the connection