powered by Jive Software

Perl Net::XMPP doesn't work correctly with Openfire 4.5.3

Hello,
I am trying to use perl script to send message to openfire.

#!/usr/bin/perl  

use strict;  
use Net::XMPP;

my ($recip, $msg) = @ARGV;
if(! $recip || ! $msg) {  
    print 'Syntax: $0 <recipient> <message>\n';  
    exit;  
}
my $con = new Net::XMPP::Client();  
my $status = $con->Connect(  
    hostname => 'myhost',  
    connectiontype => 'tcpip',  
    tls => 1);  
die('ERROR: XMPP connection failed') if ! defined($status);  
my @result = $con->AuthSend(  
    hostname => 'mydomain',  
    username => 'myuser',  
    password => 'mypass');  
die('ERROR: XMPP authentication failed') if $result[0] ne 'ok';  
die('ERROR: XMPP message failed') if ($con->MessageSend(to => $recip, body => $msg) != 0);  
print 'Success!\n';

The script sends message sometimes, but sometimes it hangs and then fails with:

Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1829.
AuthIQAuth requires a resource arguement at /home/feelsafe/xmpp.pl line 17.
Use of uninitialized value $sid in concatenation (.) or string at /usr/share/perl5/XML/Stream.pm line 2740.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 2742.
Use of uninitialized value $sid in concatenation (.) or string at /usr/share/perl5/XML/Stream.pm line 1668.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1669.
Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/XML/Stream.pm line 1669.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1671.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1673.
Use of uninitialized value in numeric eq (==) at /usr/share/perl5/XML/Stream.pm line 1673.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1675.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 1678.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 2620.
Use of uninitialized value $sid in concatenation (.) or string at /usr/share/perl5/XML/Stream.pm line 2740.
Use of uninitialized value $sid in hash element at /usr/share/perl5/XML/Stream.pm line 2742.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 440.
Use of uninitialized value in hash element at /usr/share/perl5/Net/XMPP/Connection.pm line 433.
ERROR: XMPP authentication failed at /home/feelsafe/xmpp.pl line 21.

The funny thing is that whenever I execute the script with strace, it works all the time.

Similar issue I’ve met with xmppcd which uses libstrophe: the daemon fails to authenticate and hanging until reconnect timeout is reached, but sometimes the authorization succeeds.

Is there any workaround to make it working, without running through strace all the time?