1

After using Sys::SigAction timeout_call for timeouts from the answer in my previous question (note: this time im using WWW::Mechanize instead of WWW::Mechanize::Timed), my 60 second timeout alarms were working correctly. And for a while I thought I was using Crypt::SSLeay (Net::SSL) for SSL but after looking at it closer I realized the code was using Net::SSLeay (IO::Socket::SSL), for some reason I thought WWW::Mechanize automatically used Crypt::SSLeay. I noticed an improvement in response times (50% faster) for SSL pages after I started using Net::SSL. But now my 60 second timeouts are failing and running passed 60 seconds again! If I take out use Net::SSL then my Sys::SigAction timeouts (timeout_call) will work but the SSL pages dont load as quickly. So I have two questions.

  1. Does Crypt::SSLeay (Net::SSL) provide a faster SSL algorithm than Net::SSLeay (IO::Socket:SSL)?

  2. How do I get my timeouts working again with Net::SSL? (Maybe this is a trade off I have to decide on?)

Code:

use Net::SSL
use WWW::Mechanize;
use HTTP::Cookies;
use Sys::SigAction qw(timeout_call);
use Time::HiRes qw(time); #also for use with sigaction?

my ($start_time, $end_time) = 0;

my $ua = WWW::Mechanize->new(
autocheck => 0, #turning off autocheck becuase any get errors will be fatal need to check for errors ourselves
ssl_opts => { verify_hostname => 0 } # if not set to 0 then Crypt::SSLeay will complain that it cant resolve hostnames
);

my $cookies = HTTP::Cookies->new(
autosave => 1
);

$ua->cookie_jar($cookies);

$ua->agent_alias("Windows IE 6");

if ( timeout_call( 60 ,sub { $start_time = time(); $ua->get('https://secure.site.com'); $end_time = time();} ))
{
   print "index page timed out\n" ;
   exit;
}

my $total_index_time = sprintf '%.3f', ($end_time - $start_time);

print "index load time: $total_index_time\n";

unless($ua->success){
   print "Error: " . $ua->status;
   exit;
}
...

modules loaded with use Net::SSL -

Crypt/SSLeay/CTX.pm

Crypt/SSLeay/X509.pm

Crypt/SSLeay.pm

Net/SSL.pm

Crypt/SSLeay/MainContext.pm

modules loaded without use Net::SSL -

Net/SSLeay.pm

IO/Socket/SSL.pm

/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/auto/Net/SSLeay/randomize.al

/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/auto/Net/SSLeay/autosplit.ix

Community
  • 1
  • 1

0 Answers0