[go-nuts] Re: Capture Outgoing Port for a HTTP Request

2020-10-14 Thread ryan...@gmail.com
My timeout is configurable, but I usually set it to 5 or 10 seconds. Plenty of time for a TLS handshake. Based on the code you gave me, increasing the timeout to 5 seconds, and changing the target endpoint to match the behavior I'm seeing, this is the output. Get Conn: <>:<> Conn start: tcp <>

[go-nuts] Re: Capture Outgoing Port for a HTTP Request

2020-10-14 Thread Urjit Singh Bhatia
It depends on how far down the connection process it reached before timing out... What is the timeout setting your http client? Try this example: func main() { req, _ := http.NewRequest("GET", "https://deelay.me/300/https://google.com";, nil) trace := &httptrace.ClientTrace{ GetConn: func(host

[go-nuts] Re: Capture Outgoing Port for a HTTP Request

2020-10-13 Thread ryan...@gmail.com
One problem came up. Sorry for the false positive. How can I capture this information for a request which failed to connect? If a connection times out with, say "context deadline exceeded (Client.Timeout exceeded while awaiting headers)", the local outgoing port is not captured. I'm not seeing

[go-nuts] Re: Capture Outgoing Port for a HTTP Request

2020-10-08 Thread ryan...@gmail.com
That was exactly what I was looking for. Thank you! On Thursday, October 8, 2020 at 1:12:39 PM UTC-5 urji...@gmail.com wrote: > Hi Ryan, > > You can get it via httptrace (https://blog.golang.org/http-tracing) > > Example: > req, _ := http.NewRequest("GET", "http://example.com";, nil) > trace

[go-nuts] Re: Capture Outgoing Port for a HTTP Request

2020-10-08 Thread urji...@gmail.com
Hi Ryan, You can get it via httptrace (https://blog.golang.org/http-tracing) Example: req, _ := http.NewRequest("GET", "http://example.com";, nil) trace := &httptrace.ClientTrace{ GotConn: func(connInfo httptrace.GotConnInfo) { fmt.Printf("Got Conn: