Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Server closed connection without sending any data back

by sherbertpunt (Initiate)
on Feb 26, 2013 at 13:09 UTC ( #1020687=perlquestion: print w/ replies, xml ) Need Help??
sherbertpunt has asked for the wisdom of the Perl Monks concerning the following question:

I am tring to write a new script using use LWP::UserAgent

#!/usr/bin/perl -w use strict; use warnings; use LWP::UserAgent; use JSON qw( decode_json ); use Data::Dumper; use Nagios::Plugin; use FindBin qw($Bin); use lib "$Bin/../lib"; my $jboss_url = 'http://admin:jboss@10.208.30.77:9990/management/?oper +ation=resource&name=server-state&include-runtime=true&json.pretty'; my $ua = LWP::UserAgent->new; $ua->credentials('10.208.30.77:9990','something','admin','jboss'); my $response = $ua->get ( $jboss_url ); print $response; my $json = $response->decoded_content; print Dumper $json;

My problem is i am getting the following error and I am not sure how to fix it..

./check_jboss_state.pl HTTP::Response=HASH(0x1448eb0)$VAR1 = 'Server closed connection withou +t sending any data back at /usr/local/nagios/perl/lib/Net/HTTP/Method +s.pm line 345. ';

An Update i have now got it working... and here's how needless to say it was my lack of understanding... In the end I amended

my $jboss_url = 'http://admin:jboss@10.208.30.77:9990/management/?oper +ation=resource&name=server-state&include-runtime=true&json.pretty';

To

$jboss_url = 'http://10.208.30.77:9990/management/?operation=resource& +name=server-state&include-runtime=true&json.pretty';

and this

$ua->credentials('10.208.30.77:9990','something','admin','jboss');

to this

$ua->credentials('10.208.30.77:9990','ManagementRealm','admin','jboss' +);
All is well again

Comment on Server closed connection without sending any data back
Select or Download Code
Re: Server closed connection without sending any data back
by sundialsvc4 (Monsignor) on Feb 26, 2013 at 13:27 UTC

    I would start by entering that exact URL-string on a web browser, while running the browser debugger (e.g. Firebug), in order to easily see what is going and coming across the wire.

    Next, do the same thing on the server side:   examine the logs.

Re: Server closed connection without sending any data back
by blue_cowdawg (Prior) on Feb 26, 2013 at 13:42 UTC

    Something to consider: some web servers are "agent sensitive". Check out this doco:

    $ua->agent('Checkbot/0.4 ' . $ua->_agent); $ua->agent('Checkbot/0.4 '); # same as above $ua->agent('Mozilla/5.0'); $ua->agent(""); # don't identify
    I'd pick something benign like 'Mozilla/5.0' to set your agent's ID to and you may have more success. I've run into this issue a few times...


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1020687]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (16)
As of 2014-08-27 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (238 votes), past polls