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

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@ +ation=resource&name=server-state&include-runtime=true&json.pretty'; my $ua = LWP::UserAgent->new; $ua->credentials('','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..

./ HTTP::Response=HASH(0x1448eb0)$VAR1 = 'Server closed connection withou +t sending any data back at /usr/local/nagios/perl/lib/Net/HTTP/Method 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@ +ation=resource&name=server-state&include-runtime=true&json.pretty';


$jboss_url = ' +name=server-state&include-runtime=true&json.pretty';

and this


to this

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

Comment on Server closed connection without sending any data back
Select or Download Code
Replies are listed 'Best First'.
Re: Server closed connection without sending any data back
by blue_cowdawg (Monsignor) 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
Re: Server closed connection without sending any data back
by sundialsvc4 (Abbot) 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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2015-10-04 18:26 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (104 votes), past polls