Net::XMPP

Tried out Net::XMPP for the first time against a test Openfire server. Trials and tribulations follow.

Documentation for this is pretty spotty. Not in terms of quantity, but quality. At least for a newcomer to the world of streaming XML.

First, a couple of things on setting this up.

The RHEL packages for Net::XMPP (perl-Net-XMPP) and a dependency, XML::Stream (perl-XML-Streams) both have problems that led me to remove them and then re-install from CPAN.

In addition to the latest XML::Stream, I also had to modify Net::XMPP’s Protocol.pm module by commenting out lines 1807 to 1810. Without this change the module would return errors when it tried to make uninvited SASL connection to the chat server (on RHEL 6 most modules installed from CPAN are located under /usr/local/share/perl5).

Once I got past that, this little test script worked just fine:

#!/usr/bin/perl -w
# Simple XMPP client test script
use Net::XMPP;
use Net::XMPP::Client;

my $xmppUsr = "chatuser";
my $xmppPass = "xxxxx";
my $xmppDomain = "im.example.com";
my $xmppHost = "server23.example.com";

my $conn = Net::XMPP::Client->new( debuglevel=>'1');

$conn->Execute(
            hostname => $xmppDomain,
            tls => '1',
            username => $xmppUsr,
            password => $xmppPass,
        );

my $status = $conn->Connected();
print "is connected: ", $status, "n";
$conn->Disconnect;

__END__;

References:

Perl – Net::Jabber (XML::Stream), and Authen::SASL

Ubuntu Bug #300750

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).