Subject: | not-authorized in win32, works fine in linux |
Using the exact same code, it works well in Linux but not in Windows (XP
Pro, ActivePerl 5.10). Using strace, I've gathered the list of perl
modules required and tested to be sure they were available in Windows
(they are). Anyone get this to work in Windows?
It doesn't seem to matter if I choose TLS or not.
Attached is the code I'm using in my test. User auth info is set to
nonsense values, of course.
Subject: | test2.pl |
use strict;
use Authen::SASL qw(Perl);
use Net::XMPP qw(Client);
use Megagram::ResolveSRV;
my $VERSION = '0.01';
my $xmpp = Net::XMPP::Client->new();
$xmpp->SetCallBacks(message => \&xmppHandler,
presence => \&xmppHandler,
iq => \&xmppHandler);
my $domain = 'example.com';
my $username = 'bobthebuilder';
my $password = 'yeswecan';
sub xmppConnect
{
my $rsrv = Megagram::ResolveSRV->new;
my @hosts = $rsrv->resolve('_xmpp-server._tcp.'.$domain);
unless ($hosts[0])
{
print qq($domain doesn't appear to offer XMPP service.\n);
return undef;
}
my $status;
foreach my $host (@hosts)
{
my $target = $host->{target};
my $port = $host->{port};
printf("Attempting to connect to %s:%s\n", $target, $port);
$status = $xmpp->Connect(hostname => $target,
port => $port,
componentname => $domain,
tls => 1);
last if defined($status);
}
unless (defined($status))
{
print qq(ERROR: XMPP service unavailable: $!\n);
return undef;
}
$xmpp->{STREAM}->{SIDS}->{$xmpp->{SESSION}->{id}}->{hostname} = $domain;
my @result = $xmpp->AuthSend(username => $username,
password => $password,
resource => 'TestClient_'.$VERSION);
unless ($result[0] eq 'ok')
{
print qq(ERROR: Auth failed: $result[0] - $result[1]\n);
return undef;
}
$xmpp->RosterGet();
$xmpp->PresenceSend(status => "Testing.");
$xmpp->{presence}->{"$username\@$domain"} = "Testing.";
return 1;
}
sub xmppHandler
{
my ($sid, $event) = @_;
my $type = $event->GetType() || $event->{TREE}->{TAG} || 'unknown';
print qq(XMPP-EVENT: $type\n);
use Data::Dumper;
print Dumper($event);
#runModule(command => '_xmpp_'.$type, sid => $sid, event => $event);
}
while (1) # process loop
{
if ($xmpp->Connected())
{
xmppConnect() if ($xmpp->Process(1) eq undef);
}
else
{
xmppConnect() or die(qq(Can't connect to XMPP.\n));
}
sleep(1);
}