powered by Jive Software

Net::Jabber: msgs to chat room never show up

I have a perl script using Net::Jabber that works just fine messaging a user, but when I try and use the same thing to send to a chat room, there are no error messages in openfire logs (even in debug mode) and the message isn’t received. The following code works sending to individual users. (I have tried sendxmpp, but was hoping to use this script instead if possible).

IE

RECIPIENT => ‘testuser@chatter’; # WORKS

RECIPIENT => ‘testroom@conference.chatter’; #DOESN’T WORK

the message on the group chat setup window says:

Below is an overview of the Group Chat Rooms in the service conference.chatter . From here you can view the rooms, edit their properties, and create new rooms.

Ideas?

#!/usr/bin/perl

use strict;

use Net::Jabber qw( Client );

use constant RECIPIENT => ‘testroom@conference.chatter’;

use constant SERVER => ‘10.4.149.123’;

use constant PORT => 5222; # Port to connect to

use constant USER => ‘user’;

use constant PASSWORD => ‘pwd’;

use constant RESOURCE => ‘perlscript’;

my $connection = Net::Jabber::Client->new();

$connection->Connect( “hostname” => SERVER,

“port” => PORT )

or die “Cannot connect ($!)\n”;

my @result = $connection->AuthIQAuth( “username” => USER,

“password” => PASSWORD,

“resource” => RESOURCE );

if ($result[0] ne “ok”) {

die “Ident/Auth with server failed: $result[0] - $result[1]\n”;

}

my $date = dtg(time);

my $bbmessage = $ARGV[0];

my $msg = Net::Jabber::Message->new();

$msg->SetMessage( “to” => RECIPIENT,

“body” => join("\n", “$date”, “$bbmessage”) );

$connection->Send($msg);

$connection->Disconnect();

exit;

sub dtg {

my ($string) = @_;

my ($time_str);

$time_str = localtime($string);

return substr($time_str,4,15);

}

This is what I had to do to get mine to work.

$Connection->MUCJoin(

room=>“testroom”,

server=>“conference.chatter”,

nick=>“testuser”

);

$msg->SetMessage(

“type” => “groupchat”,

“to” => “testroom@conference.chatter”,

“body” => “your message here”,

);

I find it interesting that the Net::Jabber distribution has been out since 2004, yet I find little in the way of examples out there to get it working.

I hope that this works for you.

Thanks for the reply. I am hoping to deploy this solution across our dev network for a more realtime status of our logs; Q4. It looks solid.