R
R
Roman2020-06-28 14:13:51
go
Roman, 2020-06-28 14:13:51

Golang, why does a network timeout error occur when executing inside AWS Lambda?

Hello!

There is a function (written in Go) in AWS lambda. I'm trying to make an HTTPS request to a resource, at first there was an error " TLS handshake timeout ", I specified custom transport settings, while executing it began to crash with the error " dial tcp ip: 443: i / o timeout; ", raised the timeout for the http client, now it crashes with the error " context deadline exceeded (Client.Timeout exceeded while awaiting headers); " and now I'm a little confused, it's not clear where to dig further.

I initialize the HTTP client like this:

t := &http.Transport{
  Proxy: http.ProxyFromEnvironment,
  TLSHandshakeTimeout: 10 * time.Second,
  TLSClientConfig: &tls.Config{
    CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384},
  },
}
client := http.Client{Transport: t, Timeout: time.Second * 10}


UPD
The function is not added to the VPC, in the lambda settings the memory limit is set to 128 MB, 20 seconds timeout. The logs in Cloud watch are as follows:
2020-06-27T22:27:20.663+07:00 START RequestId: ae444070-b2bb-4651-9257-e67989c5bad3 Version: $LATEST
  
2020-06-27T22:27:20.663+07:00 Error: Post "https://api.dtf.ru/v1.8/entry/create": context deadline exceeded (Client.Timeout exceeded while awaiting headers);

END RequestId: ae444070-b2bb-4651-9257-e67989c5bad3 

2020-06-27T22:27:20.665+07:00 REPORT RequestId: ae444070-b2bb-4651-9257-e67989c5bad3 Duration: 0.76 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 37 MB

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question