Jabber4r

  • Thread starter Neil Mc Laughlin
  • Start date
N

Neil Mc Laughlin

Hi all,

I want to write a jabber bot in ruby using the Jabber4r library. The first
generation bot will just logon to the jabber server without throwing an
exception, but I haven't got that far yet.

This is more a jabber issue than a ruby issue, but maybe someone here uses
jabber4r. Transcripts are below, including xml. Briefly, when the script
trys to logon, the server refuses to authorize the connection. The same uid
password works fine with the rhymbox or exodus jabber clients.


Software versions below.
Ruby version: ruby 1.8.0 (2003-08-04) [i386-mswin32]
Jabber version: Jabber4r 0.6.0 for Ruby 1.8.1
Running on win 2k with Cygwin. uname -a output follows:
CYGWIN_NT-5.0 neil 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown unknown
Cygwin


This is the script.
#!/usr/bin/env ruby
require 'jabber4r/jabber4r'
Jabber::DEBUG = true
session = Jabber::Session.bind('neilmcl@jabber', 'password', 5222, true)

nb: 'password' isn't my real password.

This is a transcript of the script running.
bash-2.05b$ jab.rb
SENDING:
<?xml version="1.0" encoding="UTF-8" ?><stream:stream to="jabber"
xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
RECEIVED:

<stream:stream xmlns:stream"http://etherx.jabber.org/streams" from"jabber"
id"407275C1" xmlns"jabber:client"/>
SENDING:
<iq type="set" id="2">
<query xmlns="jabber:iq:auth"><username>neilmcl</username>
<digest>a729db796aa737fb20755a154689a22c6c423bce</digest>
<resource/>
</query>
</iq>
RECEIVED:

<iq type"error" id"2">
<error code"406">Not Acceptable</error>
<query xmlns"jabber:iq:auth">
<resource/>
<digest sid"407275C1">a729db796aa737fb20755a154689a22c6c423bce</digest>
<username>neilmcl</username>
</query>
</iq>
/jab.rb:7: warning: already initialized constant DEBUG
d:/ruby/lib/ruby/site_ruby/1.8/jabber4r/session.rb:141:in `bind':
Authentication failed (RuntimeError)
from ./jab.rb:9
bash-2.05b$

This is a transcript of the equivalent exodus login.
SENT: <stream:stream to="jabber" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams" version="1.0" >
RECV: <?xml version='1.0'?><stream:stream
xmlns:stream='http://etherx.jabber.org/streams' id='40727C56'
xmlns='jabber:client' from='jabber'>
SENT: <iq id="jcl_7" type="get"><query
xmlns="jabber:iq:auth"><username>neilmcl</username></query></iq>
RECV: <iq id='jcl_7' type='result'><query
xmlns='jabber:iq:auth'><username>neilmcl</username><password/><digest/><sequ
ence>495</sequence><token>3F040A38</token><resource/></query></iq>
SENT: <iq id="jcl_8" type="set"><query
xmlns="jabber:iq:auth"><username>neilmcl</username><resource>Exodus</resourc
e><hash>acfb2bd52679a19c25bb758894ac905e7f308689</hash></query></iq>
RECV: <iq id='jcl_8' type='result'/>

Cheers everyone,
Neil
 
B

Ben Schumacher

Neil-

My guess is that there is a problem with the SHA1 hashing. You might try
to do authentication without digest auth and see if that works. I assume
"jabber" is a an entry in your /etc/hosts, correct? When you
authenticate using Exodus, are you using the same Jid?

Cheers,

bs.
Hi all,

I want to write a jabber bot in ruby using the Jabber4r library. The first
generation bot will just logon to the jabber server without throwing an
exception, but I haven't got that far yet.

This is more a jabber issue than a ruby issue, but maybe someone here uses
jabber4r. Transcripts are below, including xml. Briefly, when the script
trys to logon, the server refuses to authorize the connection. The same uid
password works fine with the rhymbox or exodus jabber clients.


Software versions below.
Ruby version: ruby 1.8.0 (2003-08-04) [i386-mswin32]
Jabber version: Jabber4r 0.6.0 for Ruby 1.8.1
Running on win 2k with Cygwin. uname -a output follows:
CYGWIN_NT-5.0 neil 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown unknown
Cygwin


This is the script.
#!/usr/bin/env ruby
require 'jabber4r/jabber4r'
Jabber::DEBUG = true
session = Jabber::Session.bind('neilmcl@jabber', 'password', 5222, true)

nb: 'password' isn't my real password.

This is a transcript of the script running.
bash-2.05b$ jab.rb
SENDING:
<?xml version="1.0" encoding="UTF-8" ?><stream:stream to="jabber"
xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
RECEIVED:

<stream:stream xmlns:stream"http://etherx.jabber.org/streams" from"jabber"
id"407275C1" xmlns"jabber:client"/>
SENDING:
<iq type="set" id="2">
<query xmlns="jabber:iq:auth"><username>neilmcl</username>
<digest>a729db796aa737fb20755a154689a22c6c423bce</digest>
<resource/>
</query>
</iq>
RECEIVED:

<iq type"error" id"2">
<error code"406">Not Acceptable</error>
<query xmlns"jabber:iq:auth">
<resource/>
<digest sid"407275C1">a729db796aa737fb20755a154689a22c6c423bce</digest>
<username>neilmcl</username>
</query>
</iq>
./jab.rb:7: warning: already initialized constant DEBUG
d:/ruby/lib/ruby/site_ruby/1.8/jabber4r/session.rb:141:in `bind':
Authentication failed (RuntimeError)
from ./jab.rb:9
bash-2.05b$

This is a transcript of the equivalent exodus login.
SENT: <stream:stream to="jabber" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams" version="1.0" >
RECV: <?xml version='1.0'?><stream:stream
xmlns:stream='http://etherx.jabber.org/streams' id='40727C56'
xmlns='jabber:client' from='jabber'>
SENT: <iq id="jcl_7" type="get"><query
xmlns="jabber:iq:auth"><username>neilmcl</username></query></iq>
RECV: <iq id='jcl_7' type='result'><query
xmlns='jabber:iq:auth'><username>neilmcl</username><password/><digest/><sequ
ence>495</sequence><token>3F040A38</token><resource/></query></iq>
SENT: <iq id="jcl_8" type="set"><query
xmlns="jabber:iq:auth"><username>neilmcl</username><resource>Exodus</resourc
e><hash>acfb2bd52679a19c25bb758894ac905e7f308689</hash></query></iq>
RECV: <iq id='jcl_8' type='result'/>

Cheers everyone,
Neil
 
R

Richard Kilmer

Is it possible to upgrade your Ruby installation to Ruby 1.8.1?

As you see, you have Jabber4r 0.6.0 which is for 1.8.1 and Ruby 1.8.0.

The issue is I have had struggles with REXML and Jabber4r.

I will, I will, I will isolate these problems and either give folks a
specific solution (like "upgrade to rexml xxx"/fail) or make it work
in all cases.

Let me know (directly) if this works.

Best,

Rich
 
N

Neil Mc Laughlin

Thanks for the response. I had previously tried using a password and
couldn't get that working either. I've got it working now though. I needed
to add a require statement to patch rexml and also append a resource at the
end of the Jid. Without this patch, appending a resource just caused the
process to hang.
You guessed correctly about 'jabber' being in my hosts file.


The code is still a bit rough but it does work. I can have a conversation
with 'bob' the bot. It now reads as follows.

require 'jabber4r/jabber4r'
require 'jabber4r/rexml_1.8_patch'
# Jabber::DEBUG = true

begin
session = Jabber::Session.bind('bob@jabber/Ruby', 'passwd', 5222, true)
msg = session.new_message('neilmcl@jabber')
msg.set_subject('test message')
msg.set_body('test transmission')
msg.send
mythread = Thread.current
mlid = session.add_message_listener {|message|
message.reply.set_body("Echo: #{message.body} :-0").send
mythread.wakeup if message.body=="shutdown"
}
Thread.stop
session.delete_message_listener(mlid)
rescue Exception => error
puts error
ensure
session.release if session
end


Cheers,
Neil.

----- Original Message -----
From: "Ben Schumacher" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Wednesday, April 07, 2004 7:55 PM
Subject: Re: Jabber4r

Neil-

My guess is that there is a problem with the SHA1 hashing. You might try
to do authentication without digest auth and see if that works. I assume
"jabber" is a an entry in your /etc/hosts, correct? When you
authenticate using Exodus, are you using the same Jid?

Cheers,

bs.
Hi all,

I want to write a jabber bot in ruby using the Jabber4r library. The first
generation bot will just logon to the jabber server without throwing an
exception, but I haven't got that far yet.

This is more a jabber issue than a ruby issue, but maybe someone here uses
jabber4r. Transcripts are below, including xml. Briefly, when the script
trys to logon, the server refuses to authorize the connection. The same uid
password works fine with the rhymbox or exodus jabber clients.


Software versions below.
Ruby version: ruby 1.8.0 (2003-08-04) [i386-mswin32]
Jabber version: Jabber4r 0.6.0 for Ruby 1.8.1
Running on win 2k with Cygwin. uname -a output follows:
CYGWIN_NT-5.0 neil 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown unknown
Cygwin


This is the script.
#!/usr/bin/env ruby
require 'jabber4r/jabber4r'
Jabber::DEBUG = true
session = Jabber::Session.bind('neilmcl@jabber', 'password', 5222, true)

nb: 'password' isn't my real password.

This is a transcript of the script running.
bash-2.05b$ jab.rb
SENDING:
<?xml version="1.0" encoding="UTF-8" ?><stream:stream to="jabber"
xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
RECEIVED:

<stream:stream xmlns:stream"http://etherx.jabber.org/streams" from"jabber"
id"407275C1" xmlns"jabber:client"/>
SENDING:
<iq type="set" id="2">
<query xmlns="jabber:iq:auth"><username>neilmcl</username>
<digest>a729db796aa737fb20755a154689a22c6c423bce</digest>
<resource/>
</query>
</iq>
RECEIVED:

<iq type"error" id"2">
<error code"406">Not Acceptable</error>
<query xmlns"jabber:iq:auth">
<resource/>
<digest sid"407275C1">a729db796aa737fb20755a154689a22c6c423bce</digest>
<username>neilmcl</username>
</query>
</iq>
./jab.rb:7: warning: already initialized constant DEBUG
d:/ruby/lib/ruby/site_ruby/1.8/jabber4r/session.rb:141:in `bind':
Authentication failed (RuntimeError)
from ./jab.rb:9
bash-2.05b$

This is a transcript of the equivalent exodus login.
SENT: <stream:stream to="jabber" xmlns="jabber:client"
xmlns:stream="http://etherx.jabber.org/streams" version="1.0" >
RECV: <?xml version='1.0'?><stream:stream
xmlns:stream='http://etherx.jabber.org/streams' id='40727C56'
xmlns='jabber:client' from='jabber'>
SENT: <iq id="jcl_7" type="get"><query
xmlns="jabber:iq:auth"><username>neilmcl</username></query></iq>
RECV: <iq id='jcl_7' type='result'><query
xmlns='jabber:iq:auth'> said:
ence>495</sequence><token>3F040A38</token><resource/></query></iq>
SENT: <iq id="jcl_8" type="set"><query
xmlns="jabber:iq:auth"> said:
e><hash>acfb2bd52679a19c25bb758894ac905e7f308689</hash></query></iq>
RECV: <iq id='jcl_8' type='result'/>

Cheers everyone,
Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top