Stetec has asked for the wisdom of the Perl Monks concerning the following question:

I am running RT 4.4.2 on Apache/2.4.25. I want to make a GET request to server from my custom page inside RT. Here is the relevant part of code:
#!/usr/bin/perl use strict; use warnings; use IO::Socket::SSL 'debug3'; use LWP::UserAgent; use LWP::ConsoleLogger::Everywhere (); use JSON; BEGIN { $ENV{HTTPS_DEBUG} = 1; $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = 'IO::Socket::SSL'; # force + LWP::UserAgent to use Net::SSL in case that IO::Socket::SSL is insta +lled too } sub log_list { my $par = shift; my $list = shift; my $query = "https://server.com/script.cgi?action=aaa&par=" . $par + . "&"; my $ua = LWP::UserAgent->new(); $ua->ssl_opts( SSL_cert_file => '/path/to/cert', SSL_key_file => '/path/to/key', SSL_version => 'TLSv1_2', verify_hostname => 0, ); my $res = $ua->get($query); if($res->is_success) { my $json = $res->decoded_content; my $decoded_json = decode_json($json); push (@$list, @{$decoded_json->{'result'} }); } else { die $res->status_line; } } my %list; log_list('value', \%list); print %list;

When I run this as a separate script from the command line I get the correct result. But when I put it in a Perl module and call it from HTML page in RT I get following error in logs:

DEBUG: .../IO/Socket/SSL.pm:862: ssl handshake done DEBUG: .../IO/Socket/SSL.pm:1106: SSL read error DEBUG: .../IO/Socket/SSL.pm:1106: local error: SSL read error error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

And this is in response (looks like it was created on local machine):

Status read failed: at /usr/local/share/perl/5.24.1/Net/HTTP/Methods.pm line 282.

It fails when reading from the socket. I tried this with another SSL Socket implementation - Net::SSL It works for a few hours but then errors start appearing with increasing frequency until it does not work at all. I get the same error in response. It starts to work again when I restart the apache service. Therefore I think there might be some race condition when reading from the socket and it has little to do with the handshake (from the script the handshake works all the time). I am stuck here. What can cause this and how can I get more information about this problem?

Replies are listed 'Best First'.
Re: Apache - read from socket problem
by hippo (Archbishop) on Sep 20, 2018 at 13:25 UTC
    It works for a few hours but then errors start appearing with increasing frequency until it does not work at all.

    That sounds a bit like a memory leak. Do you ever trim %list or does it just grow without limit?

      I create a new list with each request. But I never thought about memory leak and it could be something like that. Do you have any tip how can I find memory leaks in mason script? (in RT the function call is in mason script)

        Not really as I've never used Mason in production. But more generally there is lots of good stuff in the mod_perl coding guide.

        A crude yet simple way to spot if you have a memory leak is to just keep an eye on the RSS of the apache processes over time. If they keep going up you know you have a problem.

        Good luck.