Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent read timeout #423

Open
juhaszp-uhu opened this issue Feb 28, 2023 · 1 comment
Open

Intermittent read timeout #423

juhaszp-uhu opened this issue Feb 28, 2023 · 1 comment

Comments

@juhaszp-uhu
Copy link

I'm experiencing intermittent failures with LWP::UserAgent: outgoing requests fail with a read timeout error after reaching the assigned timeout.

The error message is always the same:
read timeout at /usr/share/perl5/vendor_perl/Net/HTTP/Methods.pm line 274.

There is no commonality in the target URLs except that they are all HTTPS, neither in the time, these failures happen intermittently and quite randomly. The same URL that worked the previous X times suddenly fails once. The most infuriating thing is that I can't reproduce it under experimental conditions, yet, the failures happen on the production servers a few times per day.

Relevant code that produces the faulty behavior:

	my $ua = LWP::UserAgent->new(agent => 'some string');
	$ua->env_proxy;
	$ua->timeout(6);

	my $http_payload = encode_json({
		some => 'data',
	});

	$req->l->notice("payload:", $http_payload);

	my $http_req = HTTP::Request->new;
	$http_req->method('POST');
	$http_req->uri($webhook_config->{url});
	$http_req->authorization_basic($username, $password) if $username and $password;
	# XXX headers not supported yet
	# $http_req->header('Content-Type' => 'application/json; charset=UTF-8', @$headers); ## XXX or whatever the header storage format is
	$http_req->header('Content-Type' => 'application/json; charset=UTF-8');
	$http_req->content(Encode::encode('UTF-8', $http_payload));

	my $http_res = $ua->request($http_req);

	if (not $http_res->is_success) {
		$req->l->error("Unsuccessful webhook call to $webhook_config->{url}: ".$http_res->status_line."\n".$http_res->decoded_content);
	} else {
		$req->l->notice("Webhook to $webhook_config->{url} successful");
	}
@simbabque
Copy link
Contributor

There's not much we can say about this unfortunately. Your code looks fine, and we don't see the server or the logs. I do think 6s is a rather short timeout. Is it possible the other end of the connection simply takes too long?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants