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

Hello,

I am migrating a script from one server to another. In the first server, I set the proxy variable doing ONLY this:

$ENV{HTTPS_PROXY} = $http_proxyurl . ':' . $http_proxyprt;

Then I am able to pass through the proxy absolutely no problem calling loads of different subroutines/packages using SOAP::Data, LWP::UserAgent, etc. When I move the exact same script to another server, it hangs. I have pored over Perl Monks and Google and just can't seem to figure it out... any ideas? I've tried Net::SSL, PERL_LWP_SSL_VERIFY_HOSTNAME=0, not sure what else to try... I am wondering if I have some module installed on the first server that is making it possible. Does $ENV default to any certain module? These are identical scripts.

If you need more info please let me know - thanks!!!

UPDATE: I noticed that libproxy is packaged with RHEL 6 but not 5. /usr/bin/proxy does not exist on the server where the $ENV{HTTPS_PROXY} setting does not work.

Replies are listed 'Best First'.
Re: $ENV{HTTPS_PROXY} works in one environment but not another
by stevieb (Canon) on Sep 29, 2015 at 14:27 UTC

    Are you using use strict; and use warnings;? Do they output anything? Does anything output anything prior to the hang? Have you tried putting print statements around what you believe is the problematic code to see what is going on? What OSs are we talking about here?

    Please provide us some code to look at. Also, after you've ensured strict, warnings are in effect (to rule out anything silly, like an undefined variable), put a line like this: $DB::single = 1; directly above the code that you think is hanging, then on the command line, run your script with perl -d script.pl. This will open the debugger. Press c to 'continue' to the line that you put $DB::single = 1; on. Next, press s. This will 'step' through each line, and display the actual line of code prior to executing it. Keep hitting s until you have it hang, then post the lines of code just prior to it breaking.

      Thanks! Yes I used the print trick prior to my post, but forgot to mention that is how I figured out where it is hanging. Also, yes I am using strict/warnings. I get a timeout error: Could not login to SFDC: 500 Can't connect to www.salesforce.com:443 (timeout)

      The server where it works: Red Hat Enterprise Linux Server release 6.7

      The server where it doesn't work: Red Hat Enterprise Linux Server release 5.11

      Here is the code:

      #!/usr/bin/perl use strict; use warnings; use Storable; use POSIX qw(strftime); # Parameter/host file require "host.pl"; # Environment Proxy our $http_proxyurl; our $http_proxyprt; $ENV{HTTPS_PROXY} = $http_proxyurl . ':' . $http_proxyprt; use WWW::Salesforce; our $sfdc_username; our $sfdc_password; our $sfdc_secrtokn; our $sfdc_instance; our $sfdc_soap_url; our $sfdc_versnnum; our $oper_emailadd; my $sfdc_loginatt = eval { WWW::Salesforce->login( username => $sfdc_username, password => $sfdc_password.$sfdc_s +ecrtokn, serverurl=> 'https://' . $sfdc_ins +tance . '.' . $sfdc_soap_url . $sfdc_versnnum ); }; if ($@) { warn "Could not login to SFDC: $@"; die; };

      I'm trying the debug trick but I'm able to keep stepping through every step and can't see where it might be hanging

        I'd first run strace (or the local equivalent) to see what it is doing when it hangs. That might lead me to getting a packet capture. If either of those seem to show that the Perl code is doing something wrong, then you could turn on debugger trace (to a file; see AutoTrace in perldebug) and just let it run and, after a while, check if it has been looping or was sitting waiting for something, and where.

        - tye        

Re: $ENV{HTTPS_PROXY} works in one environment but not another
by Corion (Patriarch) on Sep 29, 2015 at 14:30 UTC

    Maybe the "other" machine cannot resolve the name of $http_proxyurl? Or it cannot connect to that machine?

      Thanks! I tried hard coding the proxy url as well, and I am able to CURL in a shell script from that server to the same URL
Re: $ENV{HTTPS_PROXY} works in one environment but not another
by u65 (Chaplain) on Sep 29, 2015 at 16:34 UTC

    Just a long shot, but are the Perl and module versions different on the two hosts?

      yep!

      Server that works: v5.10.1

      Server that doesn't work: v5.8.8

      Do you think upgrading Perl could resolve it?

        Since nothing else seems to work, I would try it. I think the two Perl versions are quite different, but I don't know any details. Good luck!

        That was me, I didn't realize I wasn't logged in :)