Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.38 KB

5-Timeout-EN.md

File metadata and controls

35 lines (28 loc) · 1.38 KB

← Proxy | Timeout(中文) | Debug →


Timeout

Description

When you want to limit the time of request costing, you can set ConnectTimeout and ReadTimeout by request or client:

Default

  • defaultConnectTimeout: 5 * time.Second
  • defaultReadTimeout: 10 * time.Second

Setting

Setting on Request

// 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.

Setting on Client

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.

← Proxy | Timeout(中文) | Debug →