# XMPP4r with ejabberd

**URL:** <https://www.ruby-forum.com/t/xmpp4r-with-ejabberd/183884>\
**Category:** Ruby\
**Created:** [February 22, 2010, 9:57am UTC](https://www.ruby-forum.com/t/xmpp4r-with-ejabberd/183884 "2010-02-22T09:57:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![advenk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@advenk](https://www.ruby-forum.com/u/advenk)\
**Post date:** [February 22, 2010, 9:57am UTC](https://www.ruby-forum.com/t/xmpp4r-with-ejabberd/183884/1 "2010-02-22T09:57:22Z")

</div>

Hi,

I have been trying to get ejabberd to work with XMPP4R and have had  
partial success.

ejabberd server page has…

The name of the current ejabberd node is ejabberd@localhost

I create a new instance…

> > myJID = JID.new(‘ejabberd@localhost/Bot’)  
> > =\> #\<Jabber::JID:0x101631918 @resource=“Bot”, @node=“ejabberd”,  
> > @domain=“localhost”\>

and…

> > cl = Client.new(myJID)  
> > =\> #\<Jabber::Client:0x101629d80 @ssl\_capath=nil,  
> > @tbcbmutex=#Mutex:0x101629b00,  
> > @iqcbs=#\<Jabber::CallbackList:0x101629c18 @list=[]\>,  
> > @keepalive\_interval=60, @port=nil, @streamns=“jabber:client”,  
> > @xmlcbs=#\<Jabber::CallbackList:0x101629ce0 @list=[]\>, @tls=false,  
> > @exception\_block=nil, @processing=0, @streamid=nil,  
> > @messagecbs=#\<Jabber::CallbackList:0x101629c68 @list=[]\>,  
> > @features\_timeout=10, @host=nil, @wakeup\_thread=nil, @fd=nil,  
> > @allow\_tls=“constant”, @features\_sem=#\<Jabber::Semaphore:0x101629a88  
> > @lock=#Mutex:0x101629a38, @tickets=0,  
> > @cond=#ConditionVariable:0x101629a10\>, @last\_send=Mon Feb 22 03:35:28  
> > -0500 2010, @send\_lock=#Mutex:0x101629b78, @parser\_thread=nil,  
> > @stanzacbs=#\<Jabber::CallbackList:0x101629cb8 @list=[]\>,  
> > @ssl\_verifycb=nil, @threadblocks=[],  
> > @presencecbs=#\<Jabber::CallbackList:0x101629bc8 @list=[]\>, @status=1,  
> > @jid=#\<Jabber::JID:0x101631918 @resource=“Bot”, @node=“ejabberd”,  
> > @domain=“localhost”\>, @use\_ssl=false\>

connect it…

> > cl.connect  
> > =\> #\<Jabber::Client:0x101629d80 @ssl\_capath=nil,  
> > @tbcbmutex=#Mutex:0x101629b00, @keepaliveThread=#\<Thread:0x1015e2408  
> > sleep\>, @iqcbs=#\<Jabber::CallbackList:0x101629c18 @list=[]\>,  
> > @keepalive\_interval=60, @port=5222, @streamns=“jabber:client”,  
> > @xmlcbs=#\<Jabber::CallbackList:0x101629ce0 @list=[]\>, @tls=false,  
> > @exception\_block=nil, @processing=0, @streamid=“3202133905”,  
> > @messagecbs=#\<Jabber::CallbackList:0x101629c68 @list=[]\>,  
> > @features\_timeout=10, @host=“localhost”, @wakeup\_thread=nil,  
> > @fd=#TCPSocket:0x101618800, @allow\_tls=“constant”,  
> > @features\_sem=#\<Jabber::Semaphore:0x101629a88  
> > @lock=#Mutex:0x101629a38, @tickets=0,  
> > @cond=#ConditionVariable:0x101629a10\>, @last\_send=Mon Feb 22 03:35:46  
> > -0500 2010, @send\_lock=#Mutex:0x101629b78,  
> > @socket=#TCPSocket:0x101618800, @parser\_thread=#\<Thread:0x101609e40  
> > run\>, @stanzacbs=#\<Jabber::CallbackList:0x101629cb8 @list=[]\>,  
> > @stream\_features={}, @stream\_mechanisms=[], @ssl\_verifycb=nil,  
> > @threadblocks=[], @presencecbs=#\<Jabber::CallbackList:0x101629bc8  
> > @list=[]\>, @status=2, @parser=#\<Jabber::StreamParser:0x10160c528  
> > @started=false, @current=nil, @listener=#\<Jabber::Client:0x101629d80  
> > …\>, @stream=#TCPSocket:0x101618800\>, @jid=#\<Jabber::JID:0x101631918  
> > @resource=“Bot”, @node=“ejabberd”, @domain=“localhost”\>, @use\_ssl=false\>

authenticate…

> > cl.auth(“password”)  
> > Jabber::ClientAuthenticationFailure: closed stream  
> > from  
> > /Library/Ruby/Gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:118:in  
> > `auth’  
> > from (irb):7

and try and send a message, i get:

> > m = “kjm”  
> > =\> “kjm”
> 
> > cl.send(m)  
> > IOError: closed stream

I am not sure what is wrong, my ejabberd server screen has  
this…

By default, the ejabberd Web Admin interface is enabled. You should be  
able to connect to the admin interface and log in with the user  
krokhale@krokhale and the password you defined during the installation.

I guess i am missing something small somewhere, i would really  
appreciate your help for this!!

Thanks!!!
