[jdev] Net::Jabber Process() blocking

Jeremy Lunn jeremy at austux.net
Sun May 29 05:01:55 CDT 2005


Here's a quick and nasty script I wrote to quickly return a list of
users logged in, using service discovery (using it with jabberd 2.0s8).
It works fine 80% of the time, but sometimes it blocks at the Process 
line, even though there's a timeout specified.  Any reason as to why it
might be doing this?  Any way I could debug it?



#!/usr/bin/perl -w

binmode STDOUT, ':utf8';

use Net::Jabber qw(Client);
my $con = new Net::Jabber::Client();

$con->SetCallBacks("iq" => \&InIQ, "message" => \&InMessage);

$con->Connect(hostname=>'jabber.org.au') or die "Server connect
failed!\n";
$con->AuthSend(username=>'jeremy',
                 password=>'secret',
                 resource=>'sessions') and die "Login failed!\n";

my $req = new Net::Jabber::IQ();
$req->SetIQ(type=>"get",
            to=>"jabber.org.au");
my $query = $req->NewQuery('http://jabber.org/protocol/disco#items');
$query->SetNode('sessions');
$con->Send($req);
$con->Process(10);
$con->Disconnect();

sub InIQ {
  my ($sid,$IQ) = @_;
  if (($IQ->GetType() eq "result") and ($IQ->GetQueryXMLNS() eq
"http://jabber.org/protocol/disco#items") and
($IQ->GetQuery()->GetNode() eq 'sessions')) {
    foreach $item ($IQ->GetQuery()->GetItems()) {
      my $jid = $item->GetJID();
      if ($jid eq 'jeremy at jabber.org.au/sessions') {
        next;
      }
      print $item->GetJID() . "\n";
    }
  }
}


Any ideas?

Thanks,

Jeremy
-- 
Jeremy Lunn
Melbourne, Australia
Homepage: http://www.austux.net/



More information about the JDev mailing list