Why does 'ping' returns 'request timed out' for some hosts?
Solution 1
A ping is an ICMP packet. For comparison, web traffic or HTTP, is generally a TCP packet on port 80. A given server may be providing responses for the purpose of web traffic, but block ICMP (or be behind a firewall that blocks ICMP) and therefore you can:
- Resolve the URL to its IP address
- Connect and view the web content
But you cannot ping the IP address. The response "request timed out" is because your client sends the initial packet, waits for a reply (which will never come), and gives up at a preset timeout.
Solution 2
Because it fails to connect to the host. Just because a DNS server knows the IP a host should have, does not mean that the host in question is running and accepting connections.
Solution 3
Maybe the host is actually down, or may be the case that some sites, block ICMP traffic (protocol PING command relies on).
Solution 4
Well, ping fails to www.microsoft.com too, for example. It is because those server computers use a restrictive firewall blocking the ICMP packets from unknown hosts.
Also ping does not "CONNECT" to a host, it just dispatches a single packet to them. TCP does connection handshakes and tries very hard to keep the connection. Ping just dispatches a ICMP packet which is not guaranteed to reach its destination. Just like UDP does, for data.
If it does not each its destination or the destination throws the packet away (firewall?), you don't get an answer.
This is completely independent from http traffic which uses TCP.
Related videos on Youtube
user66875
Updated on September 17, 2022Comments
-
user66875 over 1 year
I have troubles to approach my goal in a proper, MVC kind of way: A JavaFX application that can unmarshall tickets from an XML file with JAXB and display one of one-to-many tickets from the xml file (selected with a combobox or paginator) in some textbox controls.
MainWindowController (and fxml file):
public class MainWindowController { // contains all the fxml controls private TicketAnalyzer ticketAnalyzer = new TicketAnalyzer(); private List<TicketType> tickets = new ArrayList<TicketType>(); @FXML private TextField txtNr1; //.... @FXML private TextField txtNr5; private IntegerProperty nr1; //.... private IntegerProperty nr5; @FXML protected void initialize(){ nr1 = new SimpleIntegerProperty(0); bind(); } private void bind(){ txtCurWinNr1.textProperty().bindBidirectional(nr1, new NumberStringConverter()); } @FXML private void handleBtnEvaluateAction(ActionEvent event) { List<TicketType> tickets = ticketAnalyzer.evaluate(txtXMLPath.getText()); if(tickets != null) this.tickets = tickets; updateTicket(); } private void updateTicket(){ if(this.tickets != null && this.tickets.size() > 0){ nr1.set(tickets.get(0).getPlays().get(0).getNumbers().getNumber().get(0)); } } }
Then the ´ticketAnalyzer´ class:
public class TicketAnalyzer { private String xsdPath; public void loadXSD(String xsdPath){ this.xsdPath = xsdPath; } public void evaluate(String xmlPath){ if(xsdPath.length() <= 0) return; if(!XMLValidator.validateXMLSchema(xsdPath, xmlPath)){ System.out.println("THE XML file "+xmlPath+" is not valide agains "+xsdPath); System.exit(0); } JAXBContext jc; try { jc = JAXBContext.newInstance("jaxb.ticket"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Source source = new StreamSource(new java.io.FileInputStream(xmlPath)); JAXBElement<TicketsType> root = unmarshaller.unmarshal(source,TicketsType.class); TicketsType ticketsType = root.getValue(); List<TicketType> tickets = ticketsType.getTicket(); for (TicketType ticket : tickets) displayTicket(ticket); } catch (JAXBException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
When I evaluate a new XML file, the local tickets List in the controller is updated and when I change the property value, the new value is shown in the textfield, as desired.
I am very unsure though if that approach is correct. Well it's working but it feels kind of not right. Especially because I will have to do this with many numbers and have to be able to select the ticket (right now, the 0 index is hard coded) and even a selection of the play inside of the ticket.
Isn't there a more beautiful way? I'm very new to the whole Java and JavaFX world.
Thanks a lot!!
-
Admin over 13 yearsNo host is required to respond to ping requests.
-
-
Greg over 13 yearsWhy would it not fail through browser?
-
steve over 13 years@cpx: a ping request is not an HTTP request. The host may be responding to the latter but ignoring the former.
-
Dan Grossman over 13 yearsIt's accepting TCP connections on port 80, but not ICMP connections. Nothing says a computer has to accept or respond to both.
-
Giacomo1968 almost 3 years
firewalld
is a Linux tool. This question is about Batch scripts meaning it is a Windows question.