Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Can only connect to XMPP server as anonymous@unknown.com with perl Net::XMPP module

by gauss76 (Beadle)
on Dec 03, 2019 at 08:28 UTC ( #11109581=perlquestion: print w/replies, xml ) Need Help??

gauss76 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to connect to an XMPP server and send a message to another user using the following perl code

(taken from https://roadha.us/2011/04/send-xmpp-messages-with-perl-from-the-command-line-too.html).

It works but the mesage is sent from anonymous@unknown.com. I know this because I have Pidgin running as another user on the same XMPP server and recieve the message from my perl program from anonymous@unknown.com. Pidgin also shows anonymous@unknown.com as offline!

#!/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 => 'xx.xx.xx.xx',port=>5222, connectiontype => 'tcpip',tls => 0); die('ERROR: XMPP connection failed') if ! defined($status); my @result = $con->AuthSend( username => 'Uname', password => 'PWord', resource=>'Test'); 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';

From the code I would expect to by connected as Uname. Why is this not the case?

  • Comment on Can only connect to XMPP server as anonymous@unknown.com with perl Net::XMPP module
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11109581]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2019-12-05 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (153 votes). Check out past polls.

    Notices?