So I'm binding a local IP address to use in a http request. This is the code I'm using:
localAddr, err := net.ResolveIPAddr("ip6", laddr)
if err != nil {
log.Fatal(err)
}
localTCPAddr := net.TCPAddr{
IP: localAddr.IP,
}
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
LocalAddr: &localTCPAddr,
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
}
This will panic with a i/o timeout. I'm not sure why this is happening as this code was working yesterday. The only reason I can think of is that I added several thousand IP addresses to a network interface, could this be causing the timeout, and does anyone know any solutions?
EDIT:
Error message:
Get https://myip.addr.space: dial tcp [myip]:0->[2607:5300:203:118:1:0:3:8b50]:443: i/o timeout