Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP request timeout too long using IP address that dose not exist

Status
Not open for further replies.

uprichard

Programmer
May 2, 2002
16
I am automating testing of a Network Load Balancing product.
Part of the script needs to get a page from a Virtual IP address that has been setup. Everything is fine if the IP got setup correctly but if not the following bit of code take 15 minutes to execute on my Linux box, which is way to long.

Any one have any idea how I can get it to return quicker? I tried setting a timeout on the LWP::UserAgent->new() but that did not help.

I have no problems replacing the code with something completely different if that will help.

use HTTP::Request;
use LWP::UserAgent;

my ($rc, $req, $ua);

$ua = LWP::UserAgent->new();
$req = HTTP::Request->new('GET', " $command_out=$ua->request($req)->as_string();
$rc=0 if $ua->request($req)->is_success() ;
$rc=1 if $ua->request($req)->is_info() ;
$rc=2 if $ua->request($req)->is_redirect() ;
$rc=3 if $ua->request($req)->is_error() ;

print "C = $command_out\n";
print "RC= $rc\n";
 
This works for me:
Code:
$ua->timeout(30); # timeout in 30 seconds
Make sure you set if after you create the user agent ($ua) and before the request itself. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top