← Proxy | Timeout(中文) | Debug →
When you want to limit the time of request costing, you can set ConnectTimeout
and ReadTimeout
by request or client:
defaultConnectTimeout
: 5 * time.SeconddefaultReadTimeout
: 10 * time.Second
// Set request Timeout(Only the request is effected.)
request.SetReadTimeout(10 * time.Second) // Set request ReadTimeout to 10 second.
readTimeout := request.GetReadTimeout() // Get request ReadTimeout.
request.SetConnectTimeout(5 * time.Second) // Set request ConnectTimeout to 5 second.
connectTimeout := request.GetConnectTimeout() // Get request ConnectTimeout.
When the request is not set, the client settings are used.
// Set client Timeout(For all requests which is sent by the client.)
client.SetReadTimeout(10 * time.Second) // Set client ReadTimeout to 10 second.
readTimeout := client.GetReadTimeout() // Get client ReadTimeout.
client.SetConnectTimeout(5 * time.Second) // Set client ConnectTimeout to 5 second.
connectTimeout := client.GetConnectTimeout() // Get client ConnectTimeout.