Greetings monks. After several hours, this one really has me baffled. That is to say, I'll find the answer about three minutes after posting the question. :)

My issue is that I've got a piece of code that behaves differently depending on wether I'm running it from a script on the command line, or wether I'm running it from a cgi on a mod_perl server. My problem is getting LWP::UserAgent to talk to a particular site. I've traced the issue down in the code as far as this particular line:

my $ua = LWP::Protocol::https::Socket->new( PeerAddr => 'somewhere.example.com', PeerPort => 443, Proto => 'tcp', Timeout => 180, KeepAlive => '', SendTE => 1 );

Whenever I run this from a CGI, I find that $ua contains undef. I also find that $! contains 'No such file or directory'.

However, whenever I run this from a script off the command line (running as the webserver user, so it isn't a permissions issue), it works fine!

My first question is: does anybody know of any weird interactions with perhaps either Net::HTTP or IO::Socket::INET that might make it behave differently depending on which modules are already loaded, or depending on the presence of mod_perl?

My second question: how can I trace exactly where that 'No such file or directory' is coming from? I have a feeling if I can drill down to wherever that error is being generated, I'll find my problem. However, there just doesn't seem to be a real good way to trace it!


In reply to Odd effects of mod_perl on IO::Socket or LWP::Protocol? by ehdonhon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.