title: client.Timeout exceeded while awaiting headers
body: <p>I have a lambda written in Go that communicates with a lightweight http app behind an application load balancer in AWS: </p>
  
  <pre><code>package main
  
  import (
      "io/ioutil"
      "log"
      "net/http"
      "os"
      "time"
  )
  
  func main() {
  
      for {
          req, err := http.NewRequest("GET", "http://my-app-12345.us-east-1.elb.amazonaws.com:8080", nil)
          if err != nil {
              log.Fatal("Error reading request. ", err)
          }
  
          req.Header.Set("Load-Rate", os.Getenv("LOAD"))
  
          client := &amp;http.Client{Timeout: time.Second * 10}
  
          resp, err := client.Do(req)
          if err != nil {
              log.Fatal("Error reading response. ", err)
          }
          if resp.StatusCode == http.StatusOK {
              bodyBytes, err := ioutil.ReadAll(resp.Body)
              if err != nil {
                  log.Fatal(err)
              }
              bodyString := string(bodyBytes)
              log.Println(bodyString)
          }
  
          time.Sleep(time.Duration(10) * time.Millisecond)
      }
  }
  </code></pre>
  
  <p>I've opened worldwide access on all ports in the security groups being used by both the lambda and the ALB and I can curl the endpoint fine from my home machine. However, when I attempt to run this in Lambda, I get the following in my CloudWatch logs:</p>
  
  <blockquote>
    <p>2020-06-04T07:06:31.028-05:00 Process exited before completing
    request<br>
    2020-06-04T07:06:41.100-05:00      2020/06/04 12:06:41 Error
    reading response. Get
    <a href="http://my-app-12345.us-east-1.elb.amazonaws.com:8080" rel="nofollow noreferrer">http://my-app-12345.us-east-1.elb.amazonaws.com:8080</a>:
    net/http: request canceled while waiting for connection
    (Client.Timeout exceeded while awaiting headers)<br>
    2020-06-04T07:06:41.101-05:00      2020/06/04 12:06:41 exit status 1</p>
  </blockquote>
  
  <p>I'm having  a hard time figuring out if this is a Go issue or some configuration I have wrong in AWS. I'm not very familiar at all with the error Go is throwing here.</p>