20130412 netxmpp - plembo/onemoretech GitHub Wiki

title: Net::XMPP link: https://onemoretech.wordpress.com/2013/04/12/netxmpp/ author: phil2nc description: post_id: 4639 created: 2013/04/12 16:54:17 created_gmt: 2013/04/12 20:54:17 comment_status: closed post_name: netxmpp status: publish post_type: post

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

Copyright 2004-2019 Phil Lembo