Some questions: Does this reuse a connection or keep opening new connections?tcp 1 0 ::ffff:1.2.3.4:80 ::ffff: 5.6.7.8:33196 CLOSE_WAIT 27647/httpd
If it does, a second (similar) program seems like the culprit. I can run it up to twenty times in five minutes, usually with three or four retrievals per instance. The program takes just a few seconds, and then exits completely, but apparently without telling the server to close the connection Does some way exist to close the connection when I exit the program? The second program:#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new(agent => "", timeout => 30); my $response; my $url = 'http://example.com/'; while () { sleep 60; $response = $ua->get($url); if (not ($response->is_success)) { print "Can't retrieve page: " . $response->status_line . "\n"; next; } my $page = $response->content; [... process content] }
I will usually start getting: Can't retrieve page: 500 read timeout errors after a while (while an ordinary browser will continue to access the site without problems). Thank you very much in advance for your suggestions.#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new(agent => "", timeout => 30); my $url = 'http://example.com/index.php?do=action'; [... some parameter checking] for my $i (@ARGV[2..$#ARGV]) { my $response = $ua->post($url, [ value0 => $ARGV[0], value1 => $ARGV[1], value2 => $i, Submit => 'Submit' ] ); if (not ($response->is_success)) { die "Can't retrieve page: " . $response->status_line . "\n"; + } my $page = $response->content; [... process content] }
In reply to Closing the connection by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |