stiefels.net Just another WordPress weblog

8Sep/087

Openfire and Net::XMPP

I was writing a perl script the other day which connects to my [Openfire XMPP server](http://www.igniterealtime.org/projects/openfire/index.jsp) and does some stuff (listening for incoming messages, etc.).

When I started my perl script it always failed with the error message:

ERROR: Authorization failed: error - not-authorized

After re-checking the password and username it still didn't want to work.

In the end [I found out](http://www.igniterealtime.org/community/thread/20551) that the the perl [Net::XMPP](http://search.cpan.org/~hacker/Net-XMPP-1.02/lib/Net/XMPP.pm) SASL authorization doesn't want to play with the SASL implementation in Openfire.

Modifying the Protocol.pm of Net::XMPP can help to solve this problem.
Open this file and comment out these lines (at line ~1800):

if($self->{STREAM}->GetStreamFeature($self->GetStreamID(),"xmpp-sasl"))
{
return $self->AuthSASL(%args);
}

After this little tweak Net::XMPP should talk to Openfire without grumbling.

Comments (7) Trackbacks (0)
  1. Works perfectly. Thanks for the post.

  2. You can better call AuthIQAuth in your code directly, instead of modifying the Perl code. Same result, but nicer solution.

  3. @Maarten: Thanks for the hint!

  4. Do you have an example code of what you have done?

  5. No, unfortunately, I don’t have this code anymore. But the only thing you have to do is to comment out the above shown lines.

  6. A working demo can be found here.
    http://www.particleflux.co.uk/scripts/openfire_jabber_cl.pl.txt

    If you find any other scripts on the net you can probably get them working by changing the connect line where you see AuthSend.

    so
    $connection->AuthSend(
    becomes
    $connection->AuthIQAuth(

    Good luck!

  7. Hi there…
    Despite all tries I’ve made, I can’t send a message with your script Gerric (nor with any other scripts I tried) : I reach a 503 error on jabber.org (I’m sure of my credentials, the port number, etc).
    I already tried to comment the AuthSASL in /usr/share/perl5/XMPP/Protocol.pm and I obtain the following message :

    sendxmpp: Connect: 1
    Error ‘AuthSend’: 503: [?]
    sendxmpp: Disconnect

    instead of the following one :

    sendxmpp: Connect: 1
    Error ‘AuthSend’: error: not-authorized[?]
    sendxmpp: Disconnect

    Does anybody have a trouble like this ?
    Any clue ?


Leave a comment


No trackbacks yet.