It is learned that Heartbeat employs Golang context to manage the session to do the http check, Getting “context deadline exceeds” error message while accessing a target timeout.
However, there’re 2 different cases would cause timeout:
The target host is unpingable, for example:
ping -q -c 1 <faked host>
PING <faked host> (<faked host>) 56(84) bytes of data.
--- <faked host> ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
$ time telnet <faked host>
Trying <faked host>...
telnet: Unable to connect to remote host: Connection timed out
real 2m9.623s
The port that the specific service is listening but response is very slow.
Wondering if there’s a way to distinguish these 2 kinds of cases?
I'm a bit confused here because one of these tests uses ICMP, while the other uses TCP. In the fact that they are the same error message but on different protocols. In both cases a request was sent and no result was received. It is the same error just with a different protocol.
Can you tell us more about your use case and why you need to distinguish between them?
Hello Andrew,
Sorry for confusing you.
What I’m asking here is assuming there’s a case that context deadline exceeds happened for a url check, we’re wondering to know the exact reason:
caused by the target host is unreachable
or the target host is reachable but the target port is irresponsible.
Hey @lowry, those are kind of the same thing, and also kind of different. So there are two cases where connections don't complete:
The connection is 'refused' via a TCP RST packet
The connection times out because the other side doesn't respond, or a network issue
In the second case we cannot determine if the machine is up, all we know is that we asked for info and we got no response. This stack overflow question has an excellent top answer going into detail why this is so.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.