0

I'm creating a perl script that connects to the RHN, however I seem to be struggling.

The code I have is this:

#!/usr/bin/perl
use Frontier::Client;

my $HOST = 'xmlrpc.rhn.redhat.com';

my $client = new Frontier::Client(url => "https://$HOST/rpc/api", debug=>1);
my $ver = $client->call('api->getVersion');
print "$ver\n";

This should simply connect to RHN and get the version of the API. However it returns the following:

---- request ----
<?xml version="1.0"?>
<methodCall>
<methodName>api->getVersion</methodName>
<params>
</params>
</methodCall>    
500 Connect failed: connect: Connection timed out; Connection timed out

Which I presume is an HTTP 500, and so I'm getting through to the server?

I can't ping the host, though can resolve it. I can access RHN using rhnreg_ks, so I'm not sure what's going wrong :/ The script will later do more and is currently more PoC, which isn't working out too well!

forquare
  • 45
  • 13
  • As the [documentation](https://access.redhat.com/site/documentation/en-US/Red_Hat_Network/5.0.0/html/Reference_Guide/ap-rhn-api-access.html) states: *It is worth noting that you will almost invariably use the **auth class** first*. You'll need to login first with a valid username/password... – HBruijn Jun 25 '14 at 14:20
  • Using the **auth class** and loging in yields the same error... – forquare Jun 25 '14 at 14:22
  • Try it with `$ver = $client->call('api.getVersion')` instead of `api->getVersion` and your code was correct in that requests in the api namespace do not need authentication. – HBruijn Jun 25 '14 at 14:48
  • @HBruijn, alas I get the same error :( I had initially thought it was our network (proxies are configured, and other commands work), but the fact I get a server error suggests otherwise... – forquare Jun 25 '14 at 15:49
  • For API connections to RHN the correct URL should be https://rhn.redhat.com/rpc/api/ (this is the URL is use to query our RHN account) – deagh Jun 25 '14 at 17:24
  • If you're behind a proxy I'm not certain the `http_proxy`environement variable is honoured, please try `my $proxy = 'http://poxy:port'` and `my $client = new Frontier::Client('url' => $url, 'proxy' => $proxy);` – HBruijn Jun 27 '14 at 16:02

0 Answers0