title: HTTP Server causing HTTP Client to return stream error: INTERNAL_ERROR
body: <p>I have two services running: an API (in this case, the 'server') and a client application. I have the server configured like so:</p>
  
  <pre><code>r := CreateApiRouter()
  var certManager *autocert.Manager
  certManager = &amp;autocert.Manager{
      Prompt:     autocert.AcceptTOS,
      HostPolicy: autocert.HostWhitelist(utilities.ServeHost),
      Cache: autocert.DirCache(utilities.CertCacheDir),
  }
  
  srv := &amp;http.Server{
      Handler:           r,
      Addr:       ":" + utilities.ServePort,
      ReadHeaderTimeout: 10 * time.Second,
      WriteTimeout: 90 * time.Second,
      TLSConfig: &amp;tls.Config{
          GetCertificate: certManager.GetCertificate,
          ServerName: utilities.ServeHost,
      },
  }
  
  go func() {
      // serve HTTP, which will redirect automatically to HTTPS
      h := certManager.HTTPHandler(nil)
      log.Fatal(http.ListenAndServe(":http", h))
  }()
  log.Fatal(srv.ListenAndServeTLS("", ""))
  </code></pre>
  
  <p>Recently, I have been running into an issue with long-running requests. I have an API call that takes approx. 45-60 seconds to complete.</p>
  
  <p>I then have a client making a request with the following code:</p>
  
  <pre><code>req := &amp;http.Request{
      Method:           http.MethodPatch,
      URL:              url,
      Header:           make(map[string][]string),
  }
  req.Header.Add("Authorization", "Bearer " + token)
  res, e := utilities.GetClient().Do(req)
  if e != nil {
      fmt.Print(err.Error())
      return
  }
  </code></pre>
  
  <p>The client is defined as follows:</p>
  
  <pre><code>    client = &amp;http.Client{
      CheckRedirect: func(req *http.Request, via []*http.Request) error {
          return http.ErrUseLastResponse
      },
      Jar:           nil,
      Timeout:       0,
  }
  </code></pre>
  
  <p>When a client hits this endpoint though, after around 20 seconds, e is populated with the following message:</p>
  
  <blockquote>
    <p>Patch <a href="https://api.myapi.com/endpoint" rel="nofollow noreferrer">https://api.myapi.com/endpoint</a>: stream error: stream ID 9; INTERNAL_ERROR</p>
  </blockquote>
  
  <p>From what I can gather, this is somewhat related to <a href="https://go.googlesource.com/go/+/go1.9/src/net/http/h2_bundle.go#5371" rel="nofollow noreferrer">a write timeout</a> however I set that to 90 seconds.</p>