← Endpoint | Transport(中文) | Timeout →
Default
MaxIdleConns: 100IdleConnTimeout: 90sMaxIdleConnsPerHost: 2
You can customize an http.Client to adjust these settings.
func main() {
region := "cn-beijing"
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
MaxIdleConnsPerHost: 10,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
client := &http.Client{
Transport: transport,
Timeout: 60 * time.Second,
}
config := volcengine.NewConfig().
WithRegion(region).
WithHTTPClient(client).
WithCredentials(credentials.NewEnvCredentials())
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
svc := ecs.New(sess)
}Default
https
In the SDK, disableSSL=true means using http, and disableSSL=false means using https.
func main() {
region := "cn-beijing"
config := volcengine.NewConfig().
WithRegion(region).
WithDisableSSL(true).
WithCredentials(credentials.NewEnvCredentials())
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
svc := ecs.New(sess)
}You can customize http.Client to skip certificate verification.
func main() {
region := "cn-beijing"
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
MaxIdleConnsPerHost: 10,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: transport,
Timeout: 60 * time.Second,
}
config := volcengine.NewConfig().
WithRegion(region).
WithHTTPClient(client).
WithCredentials(credentials.NewEnvCredentials())
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
svc := ecs.New(sess)
}You can customize TLS min/max versions via TLSClientConfig.
func main() {
region := "cn-beijing"
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
MaxIdleConnsPerHost: 10,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS13,
},
}
client := &http.Client{
Transport: transport,
Timeout: 60 * time.Second,
}
config := volcengine.NewConfig().
WithRegion(region).
WithHTTPClient(client).
WithCredentials(credentials.NewEnvCredentials())
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
svc := ecs.New(sess)
}Default
- No proxy
var ak, sk, region string
config = volcengine.NewConfig().
WithCredentials(credentials.NewStaticCredentials(ak, sk, "")).
WithRegion(region).WithHTTPProxy("http://your_proxy:8080").WithHTTPSProxy("http://your_proxy:8080")
sess, _ = session.NewSession(config)
client = ecs.New(sess)Supported environment variables:
http_proxy/HTTP_PROXYhttps_proxy/HTTPS_PROXY
Priority: code > environment variables.
← Endpoint | Transport(中文) | Timeout →