> On 28 Nov 2020, at 8:14 pm, b.ca...@pobox.com <b.cand...@pobox.com> wrote:
> 
> Do you see a forward or reverse DNS lookup being made?
> 
> Can you provide a standalone program which demonstrates this behaviour?
> 
> I am wondering if either (a) something is logging when the connection is 
> terminated, or (b) a new connection is automatically being made and put into 
> a pool.

Sure, please find my code here: 
https://gist.github.com/amitsaha/3963207e77f7537a5dcc3b3afa8e57ee

My experiment scenario:

1. Modify /etc/hosts to have this entry:

# 216.239.38.21 godoc.org #one of the actual IP addresses
<your local ip> godoc.org

2. Run godoc locally as: sudo ~/go/bin/godoc -http=<your local ip>:80

3. Build and run the above program:

$ go build -o application
$ ./application http://godoc.org
DNS Start Info: {Host:godoc.org}
DNS Done Info: {Addrs:[{IP:192.168.1.109 Zone:} {IP:2001:4860:4802:38::15 
Zone:} {IP:2001:4860:4802:36::15 Zone:} {IP:2001:4860:4802:32::15 Zone:} 
{IP:2001:4860:4802:34::15 Zone:}] Err:<nil> Coalesced:false}
Got Conn: {Conn:0xc000186000 Reused:false WasIdle:false IdleTime:0s}
Put Idle Conn Error: <nil>
Resp protocol: "HTTP/1.1"
Sleeping now
--------
Got Conn: {Conn:0xc000186000 Reused:true WasIdle:true IdleTime:2.00444722s}
Put Idle Conn Error: <nil>
Resp protocol: "HTTP/1.1"
Sleeping now
--------


…

In a new terminal:

1. Update /etc/hosts to have:

216.239.38.21 godoc.org
#192.168.1.109 godoc.org

2. Kill the godoc server

Then in the terminal you had the application running, you should see:

Got Conn: {Conn:0xc000186000 Reused:true WasIdle:true IdleTime:2.001646523s}
Put Idle Conn Error: <nil>
Resp protocol: "HTTP/1.1"
Sleeping now
————

# This is where the switch to the new IP happens

DNS Start Info: {Host:godoc.org}
DNS Done Info: {Addrs:[{IP:216.239.38.21 Zone:} {IP:2001:4860:4802:32::15 
Zone:} {IP:2001:4860:4802:36::15 Zone:} {IP:2001:4860:4802:38::15 Zone:} 
{IP:2001:4860:4802:34::15 Zone:}] Err:<nil> Coalesced:false}
Got Conn: {Conn:0xc0000b40b8 Reused:false WasIdle:false IdleTime:0s}
Put Idle Conn Error: <nil>
Resp protocol: "HTTP/1.1"
Sleeping now
--------
Got Conn: {Conn:0xc0000b40b8 Reused:true WasIdle:true IdleTime:2.002040265s}
Put Idle Conn Error: <nil>
Resp protocol: "HTTP/1.1"
Sleeping now

….


My go version:
$ go version
go version go1.15 darwin/amd64


Thank you,
Amit



> 
> On Saturday, 28 November 2020 at 01:27:32 UTC amits...@gmail.com wrote:
> Hi, it seems that the http client automatically performs a DNS lookup when an 
> existing connection is terminated by the server. I simulated it via changing 
> the IP address in /etc/hosts.
> 
> Can someone point me to the code where this logic is checked?
> 
> I am looking at https://golang.org/src/net/http/transport.go but haven’t 
> found something yet - quite a beginner here.
> 
> Thanks,
> Amit.
> 
> 
> -- 
> 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/86f347d0-862f-4922-b2e4-e8835858ae90n%40googlegroups.com.

-- 
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/8CC6C1E1-BA1C-46C7-A564-E5A9E7D5AA52%40gmail.com.

Reply via email to