Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

problem w/ LWP::UserAgent?

by dorianwinterfeld (Acolyte)
on May 30, 2013 at 12:17 UTC ( [id://1036034]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks - I recently upgraded to activestate perl 5.16 running on Windows Server 2003 w/ IIS6. A CGI script that has worked for years now errors with "500 Status read failed: A non-blocking socket operation could not be completed immediately.". I wrote a simple test script and the message is coming from LWP::UserAgent. I have tried debugging to no avail. I have written to an activestate forum w/ no reply yet. Is there any known problems with LWP and Perl 5.16? thanks - Dorian dorian@uaqa.com

Replies are listed 'Best First'.
Re: problem w/ LWP::UserAgent?
by derby (Abbot) on May 30, 2013 at 12:35 UTC

    Well ... an HTTP status code of 500 normally means an Internal Server Error (but this is IIS so ... ). I would check the web server logs for more information. I doubt LWP is the problem here -- more than likely it's the CGI script (unless the CGI script uses LWP).

    -derby
      Thanks for your quick reply Derby. The script does use LWP::UserAgent. Here is my stripped down test script:
      use CGI qw/:standard/; use CGI::Carp (fatalsToBrowser); require LWP::UserAgent; print header; my $ua = LWP::UserAgent->new; my $url = 'http://google.com'; my $response = $ua->get($url); if ($response->is_success) { print $response->decoded_content; # or whatever } else { die "failed: $url : ", $response->status_line; }
      So, it's dying w/ Status code 500. The server logs don't say much: "GET /scripts/prince/lwp_test.plx - 200 Mozilla/5.0+(compatible;+MSIE+10.0;+Windows+NT+6.1;+WOW64;+Trident/6.0;+EIE10;ENUSWOL)" I have run this script on two different servers, after the Perl upgrade on both, and I get the same error message.

        Is it really throwing the error with the google url or was that just a change for posting? What happens if you run the above script from the command line? Do you still get the 500? The 500 error *should* be from the server the url points to and I have a hard time believing google is throwing a 500.

        The only *recent* LWP upgrade issue that I can think of is the SSL validity check on https -- but that would throw an entirely different error I believe.

        -derby
        Could you run it with
        print $response->dump;
        (in case of failure) and paste output here?
      LWP can return fake HTTP 500 responses together with header Client-Warning => Internal Response. This means some internal error.

        Seems to me the most likely cause is that when upgrading his perl, he upgraded his entire webserver -- perhaps using something like XAMPP - and hasn't (re)tweaked the webserver runtime account to have network privileges.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: problem w/ LWP::UserAgent?
by BrowserUk (Patriarch) on May 30, 2013 at 13:47 UTC

    Works fine on 5.16.1 for me:

    C:\test\ACA>\perl64-16\bin\perl print $]; use CGI qw/:standard/; use CGI::Carp (fatalsToBrowser); require LWP::UserAgent; print header; my $ua = LWP::UserAgent->new; my $url = 'http://google.com'; my $response = $ua->get($url); if ($response->is_success) { print $response->decoded_content; # or whatever } else { die "failed: $url : ", $response->status_line; } ^Z 5.016001Content-Type: text/html; charset=ISO-8859-1 <!doctype html><html itemscope="itemscope" itemtype="htt window.google={kEI:"DlinUZt4qZfQBeOxgbAO",getEI:function r:0,ml:function(){},kHL:"en",time:function(){return(new d.onabort=function(){delete f[e]};f[e]=d;!c&&-1==b.searc a.test(c)&&google.https()?(google.ml(Error("GLMM"),!1,{s (function(){var d=!1;google.sn="webhp";google.timers={}; try{}catch(e){}})(); var _gjwl=location;function _gjuc(){var a=_gjwl.href.ind function _gjp(){(!window._gjwl.hash||!window._gjuc())&&s window._gjp&&_gjp();</script><style>#gbar,#guser{font-si f}.gsfs{font:17px arial,sans-serif}.ds{display:inline-bo ne-block;margin:0 12px}.lsb:active{background:#ccc}.lst: if (!iesg){document.f&&document.f.q.focus();document.gbq } })();</script><textarea id="csi" style="display:none"></ =gb_70 href="https://accounts.google.com/ServiceLogin?hl 048" name="q" size="57" style="color:#000;margin:0;paddi ><a href="https://plus.google.com/103583604759580854844" if(!google.xjs){window._=window._||{};window._._DumpExce le.hs.init()});if(google.j&&google.j.en&&google.j.xi){wi for(var l=c=0,m;l<b;++l)m=k[l],m.complete||"string"!=typ function n(){if(google.timers.load.t){google.timers.load </script></body></html>

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
    failed: $url :
      This is what I get:
      C:\Documents and Settings\dorian>perl
      print $];
      use CGI qw/:standard/;
      use CGI::Carp (fatalsToBrowser);
      require LWP::UserAgent;
      
      print header;
      
       my $ua = LWP::UserAgent->new;
      
       my $url = 'http://google.com';
      
       my $response = $ua->get($url);
      
       if ($response->is_success) {
           print $response->decoded_content;  # or whatever
       }
       else {
           die "failed: $url : ", $response->status_line;
       }
      ^Z
      5.016003Content-Type: text/html; charset=ISO-8859-1
      
      

      Software error:

      failed: http://google.com : 500 Status read failed: A non-blocking socket o
      peration could not be completed immediately. at - line 18.
      

      For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

      Thu May 30 13:43:04 2013 -: failed: http://google.com : 500 Status read failed : A non-blocking socket operation could not be completed immediately. at - line 18.

        Have you installed some SSL module or another?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1036034]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found