3
require 'watir-webdriver'    
begin
  url='http://localhost/test/test.php'
  ie =Watir::Browser.new:chrome
  ie.goto url
rescue Timeout::Error
  puts "time out"
  ie.close
  retry
end

This my php file:http: //localhost/test/test.php

<?php 
set_time_limit(90);
sleep(60);
echo "hello"
?>

output -> time-out, and after it error:

Errno::ECONNREFUSED (No connection could be made because the target machine actively refused it. - connect(2)).

Basically it should close the ie after time out and then again open ie and so on

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
unknownbits
  • 2,855
  • 10
  • 41
  • 81

2 Answers2

2

When you try a connect to any box, there's multiple ways the connection can be handled. If you have a firewall blocking the connection, it can either DROP (as in DROP target for netfilter) or REJECT the incoming connection.

The difference:

  • DROP means that the incoming packet is dropped (as in on the floor). There is no reply from the target. The source does not get any information as to what happened to the packet. It can only make assumptions, but not say with certainty that the packet hasn't been swallowed by a network component en route.
  • REJECT means that for the incoming packet (like a SYN request for opening a connection) a reply will be generated, stating that on the port at the target server no application is listening. This means that the packet reached it's destination and has been processed (interpreted) successfully, yet there is no application to give control of the package to.

You get connection refused, meaning that the target replied, but said that a connection cannot or will not be established (actively refused). The expected timeout only occurs when the target machine does not answer and DROPs the packet.

You can see here how connections are built and established or rejected.

0xCAFEBABE
  • 5,576
  • 5
  • 34
  • 59
2

It's probably not a problem with waitr. From this answer ( https://stackoverflow.com/a/2972662/131051 )

If this happens always, it literally means that the machine exists but that it has no services listening on the specified port, or there is a firewall stopping you.

Community
  • 1
  • 1
GSP
  • 3,763
  • 3
  • 32
  • 54