Thanks! I added the IPv6 loopback address to all my host names in /etc/hosts (i.e. "::1 mydomain.local") and it now works as expected.
I guess Go's DNS resolver was timing out at the first attempt, that's why I consistently had that 5 second delay. torsdag 1 april 2021 kl. 07:40:10 UTC+2 skrev Shulhan: > On Wed, 31 Mar 2021 01:47:43 -0700 (PDT) > Jonathan Hedrén <jonatha...@gmail.com> wrote: > > > I've set up a development environment on my MacBook Pro M1 (running > > Big Sur 11.2.3, Go 1.16.2) with a number of small Go/.Net HTTP APIs > > that are communication with each other. To replicate our production > > infrastructure I've set up /etc/hosts with ".local" domains pointing > > to 127.0.0.1. An nginx server then proxies the requests to the APIs. > > A self signed certificate is used for https. > > > > Whenever an HTTP request is sent from a Go application to any of the > > ".local" APIs, 5 seconds are added to the response time. This delay > > is not added when I use a browser to make the request, neither if I > > call an external address (for example google.com) or "localhost" from > > the Go code. It only happens when I use http.Client to request a > > ".local" domain and the behavior is consistent. > > > > I've searched the Go standard library for a "5 * time.Second" and > > found it only in a few places, including src/net/dnsconfig_unix.go so > > I guess it's related to the name resolution. > > > > Anyone got an idea about what's wrong and how it can be fixed? > > > > /Jonathan > > > > Previous discussion on this subject: > > https://groups.google.com/g/golang-nuts/c/BuMYgqMCw8I/m/pIAhmNIWBQAJ > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5f0fbf95-20b3-4cac-897d-5af1cc7c6bb4n%40googlegroups.com.