Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Debugging LWP

by tdrought (Novice)
on Feb 11, 2006 at 16:59 UTC ( #529565=perlquestion: print w/ replies, xml ) Need Help??
tdrought has asked for the wisdom of the Perl Monks concerning the following question:

Arrrrgggh! How can I debug a perl script? I have a script which used to post data to another server, retrieve info and continue on it's merry Perl ways. Within the past week, when the script runs the Post, nothing happens. The script starts, tries to connect, I suppose, then I get a CGI TimeOut error. I have narrowed it down to when it performs the Post. Per my webhoster, nothing has changed and they even rebooted the server. Here is a portion of the code:
my $useragent = LWP::UserAgent->new( protocols_allowed => ["htt +ps"] ); my $request = POST( "https://secure.mydomain.com/script.dll", $ +request_values ); my $response = $useragent->request( $request ); my @responses = split( /$request_values->{x_delim_char}/, $resp +onse->content );
Like I had started, it was working great, up to about a week agin. I did nothing. It just started timing out. Any ideas on how this can be debugged?

2006-02-12 Retitled by planetscape, as per Monastery guidelines
Original title: 'Debugging Perl'

Comment on Debugging LWP
Download Code
Re: Debugging LWP
by brian_d_foy (Abbot) on Feb 11, 2006 at 17:29 UTC

    The LWP::Debug module can help you watch what's going on.

    However, the problem might not be with your Perl script. The problem might be on the other side. Can you connect to that CGI script manually? Are you allowed to (maybe you're now blocked)? What happens when you try the same thing without using your CGI script?

    As an aside, I usually find phrases like "nothing has changed" and "I did nothing" to mean just the opposite. :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Debugging LWP
by vladb (Vicar) on Feb 11, 2006 at 17:32 UTC
    There's the interactive perl debugger that might help. Simply execute:
    perl -d <your script>
    In the debugger prompt, type "t" to set trace ON, followed by C to let the code execute. By examining the trace, you can figure out where in the code the timeout occurs. If it's at the point where your client is trying to connect to the destination host, then there's likely a network issue at play.

    There are other ways to debug it by setting LWP::UserAgent's debug on. To my recollection, there's a package variable 'Debug' that you use to toggle debugging on/off. LWP library should then spit out enough information to help you figure out if, again, its a simple network connectivity problem or something else.

    Update: Actually, you can use the convenient LWP::Debug package to troubleshoot your LWP client script:
    use LWP::Debug qw(+); # REST OF YOUR CODE
    Of course, lest I forget, another way to test connectivity to remote host is with the help of the 'telnet' utility! Eliminate network issue before starting to debug your code first. :)


    _____________________
    "We've all heard that a million monkeys banging on a million typewriters will eventually reproduce
    the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true."

    Robert Wilensky, University of California

Re: Debugging LWP
by tdrought (Novice) on Feb 11, 2006 at 18:04 UTC
    Well, I tried adding the code. Now my script has this at the top:
    use Strict; use LWP 5.803; use LWP::Debug qw(+); use HTTP::Request::Common qw( POST );
    But, I still receive a CGI Timeout: The specified CGI application exceeded the allowed time for processing. The server has deleted the process. This script is for a well known transaction, Authorize.net's AIM CC Transactioning. I do CC processing in 5 different scripts, all which don't work anymore. I can transact CC's still though, so I know my account is active. The path to Authorize.net is working. I contacted them first. I even downloaded their test Perl script. Didn't work, and it's all coded and ready to run a test transaction. Worst case, if it was Authorize.net, I would receive an error. Any other ideas? Why did the LWP::Debug not report an error? Thanks for all your help in advance. I just started this business, and not being able to process credit cards will kill it. If this is an issue with my hoster, any ideas why? Tom
      If the host is telling you they have registered a hit from your script, are they able to send you any log of that request? I would specifically look for any error messages etc.

      Try sending a POST request via the system telnet utility to eliminate your script entirely.


      _____________________
      "We've all heard that a million monkeys banging on a million typewriters will eventually reproduce
      the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true."

      Robert Wilensky, University of California

        I am running this script from a hosted Windows server. So I cannot run a telnet. But, what I just did was bring the script to my local machine which has IIS and ActivePerl installed. Install the SSLeay and tested the script locally. It ran just fine which tells me it's the hosters server which is causing the problem. I am going to call them now. Hopefully, they can get to the bottom of this, else I will have to switch servers.
Re: Debugging LWP
by holli (Monsignor) on Feb 11, 2006 at 18:28 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-11-26 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls