Debug http calls made using go http client

182 views
Skip to first unread message

krishna...@gmail.com

unread,
Aug 21, 2020, 2:59:54 PM8/21/20
to golang-nuts
Hello Gophers,

I am making multiple http calls from my go application to an external vendor's http server using the go standard http client. I've set a 10 second timeout for my context. Everything works fine. 

However, I get random timeouts in my application due to these HTTP calls. On further investigation, I found that the http calls to the vendor's server take longer than 10 seconds.
During this period of timeouts, the vendor says they've not received any HTTP requests. How do I verify that the http requests are made from my app? If the requests are made from my app, how can I figure out what's causing the delay?

I tried debugging using the HTTP client trace, but couldn't find any actionable information. Any suggestions on how to debug/fix this issue ?

Thanks
- Krishna 

Robert Engels

unread,
Aug 21, 2020, 10:46:12 PM8/21/20
to krishna...@gmail.com, golang-nuts
I would use wire shark to inspect the traffic in more detail. 

On Aug 21, 2020, at 1:59 PM, krishna...@gmail.com <krishna...@gmail.com> wrote:


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2d454dda-6670-48ef-85a2-0a42216dcd29n%40googlegroups.com.

Dimas Prawira

unread,
Aug 23, 2020, 9:44:19 AM8/23/20
to krishna...@gmail.com, golang-nuts
There are several tools which you can use to help to inspect, 

1. TCPmon, is a java-based tool for inspecting http call in between server and client. TCPmon also can be used to simulate slow connection. 

Work mechanism of TCPmon is as a proxy. So if I describe it as below

[Your apps] ---> [tcpmon] ---> [server]

2. TCPdump, is a linux app which can be use to dump TCP connection in and out. This can be help to inspect HTTP request / HTTP come to the server.

3. Traceroute
You may want to inspect / trace connection from your server to vendor's server using traceroute, maybe the problem is in the connection.

Hope that's helpful

--

Krishna Kowshik

unread,
Aug 23, 2020, 9:55:50 AM8/23/20
to Dimas Prawira, golang-nuts
Hello Dimas,

Thank you for your response. My application is running in a kubernetes cluster and I will not be able to run TCPMon or TCPDump separately, as access is restricted. I was looking for something that can be embedded within the go application.

Regards,
Krishna


Tamás Gulácsi

unread,
Aug 23, 2020, 1:06:20 PM8/23/20
to golang-nuts
You can print every step with net/http/httptrace 's ClientTrace.

Mike Spreitzer

unread,
Aug 23, 2020, 2:20:45 PM8/23/20
to Tamás Gulácsi, golang-nuts
Krishna can put a use of TCPMon or tcpdump inside the Kubernetes Pod.
Either of these things can be added to the main container, or put in
another container in the Pod.

Regards,
Mike

golan...@googlegroups.com wrote on 08/23/2020 01:06:20 PM:
d/msgid/golang-nuts/72972301-5163-4dfd-8886-1ed2b8efadc4n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages