I have a daemon that simply sleeps until it receives a SIGUSR1 signal. Upon that signal, a signal counter is incremented and a queue of sms text messages is POSTed to 2 or 3 other servers.
The big problem i often get is that the the LWP::UserAgent->request method returns after sending the request, but $response->is_success is false and $response->status_line is "500 read timeout".
I've verified that these requests are actually received by the other servers which means no real timeout actually occured.
I've also measured the time it takes to execute the LWP::UserAgent->request() method and when these 'timeouts' occur, the elapsed time is around 0.1 seconds.
This is one of the code blocks in which this bug occurs:
# Prepare HTTP request
my $ua = new LWP::UserAgent();
$ua->agent(__PACKAGE__ . "/$VERSION " . $ua->agent());
my $request = HTTP::Request->new('POST' => 'http://concorde.paratel.be/digitalfun/transport.php');
$request->content_type('text/xml');
$request->content($content);
# Send HTTP request
my $t1 = Time::HiRes::time();
my $response = $ua->request($request);
my $elapsed = Time::HiRes::time() - $t1;
$self->{$CLASS_FIELD_HTTP} = $response->status_line();
if ($response->is_success()) {
return 1;
}
else {
$self->{$CLASS_FIELD_ERROR} = 'HTTP request in ' . __PACKAGE__ . "->send_text() to concorde.paratel.be failed with status line \"" . $self->{$CLASS_FIELD_HTTP} . "\". Elapsed time = $elapsed seconds.";
return 0;
}
I think the origin of this 'timeout' is this code block in LWP::Protocol::http::SocketMethods, but I just don't understand it:
sub sysread {
my $self = shift;
if (my $timeout = ${*$self}{io_socket_timeout}) {
die "read timeout" unless $self->can_read($timeout);
}
else {
# since we have made the socket non-blocking we
# use select to wait for some data to arrive
$self->can_read(undef) || die "Assert";
}
sysread($self, $_[0], $_[1], $_[2] || 0);
}I''m using LWP 5.69 on Perl 5.6.1 on Linux.
I hope somebody can help me out on this.
Here's another clue: I used XMLRPC::Lite which itself uses SOAP::Transport::HTTP to POST many requests, but these never result in timeouts. What I see is that SOAP::Transport::HTTP patches some of the code of LWP::UserAgent - perhaps the solution lays there - but that code is not my terrain and I don't really know where to look.
I hope somebody can help.
Regards, Craig Manley
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
