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);
}