Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by gauss76 (Scribe)
on Dec 03, 2019 at 08:28 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found