Discussion:
ejabberd & XMPP4R
Spencer Cheng
2010-11-16 03:14:07 UTC
Permalink
Hi,

I am writing a custom XMPP client using XMPP4R talking to a local ejabberd server. I am having a problem with my custom XMPP client is being disconnected from the ejabberd server by a connection reset. I haven't been able to figure out whether this is a problem with how I've configured ejabberd, an XMPP4R library issue or some bug in my own XMPP client. I have tried disabling the c2s and s2s traffic shapers in ejabberd but that didn't fix anything.

There is nothing obvious (error reports, connection resets) in the ejabberd logs at the affected timestamps. My XMPP client runs happily for 15 minutes or more before it gets a connection reset while it is processing messages. If it is idle, the connection reset doesn't happen.

My xmpp client attempts to reconnect to the ejabberd server once it sees a connection reset but it is failing with an authentication exception which seems a bit strange. Why is there multiple connection to the same ejabberd server as I am seeing multiple connection failure which is triggering multiple reconnection attempts?

Does anyone have any suggestions as to where I should look? Thanks for any help.

Regards,
Spencer

------------
[...]
WARN [2010-11-15 21:34:32] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:41] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:49] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:49] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:49] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:49] :: XMPP connection failed. Reconnecting in 10s
WARN [2010-11-15 21:34:49] :: XMPP connection failed. Reconnecting in 10s
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:118:in `auth': mechanisms (Jabber::ClientAuthenticationFailure)
from /StarCDN/src/xmppclient.rb:80:in `establish_connection'
from /StarCDN/src/xmppclient.rb:44
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:387:in `call'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:387:in `send'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `initialize'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `new'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `send'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:79:in `close'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:89:in `start'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `initialize'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `new'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `start'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `initialize'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `new'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `start'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:119:in `start'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:87:in `start'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:77:in `connect'
from /var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:70:in `connect'
from /StarCDN/src/xmppclient.rb:79:in `establish_connection'
from /StarCDN/src/xmppclient.rb:44
Spencer Cheng
2010-11-23 15:00:18 UTC
Permalink
Hi Everyone,
Post by Spencer Cheng
I am writing a custom XMPP client using XMPP4R talking to a local ejabberd server. I am having a problem with my custom XMPP client is being disconnected from the ejabberd server by a connection reset. I haven't been able to figure out whether this is a problem with how I've configured ejabberd, an XMPP4R library issue or some bug in my own XMPP client. I have tried disabling the c2s and s2s traffic shapers in ejabberd but that didn't fix anything.
There is nothing obvious (error reports, connection resets) in the ejabberd logs at the affected timestamps. My XMPP client runs happily for 15 minutes or more before it gets a connection reset while it is processing messages. If it is idle, the connection reset doesn't happen.
My xmpp client attempts to reconnect to the ejabberd server once it sees a connection reset but it is failing with an authentication exception which seems a bit strange. Why is there multiple connection to the same ejabberd server as I am seeing multiple connection failure which is triggering multiple reconnection attempts?
Does anyone have any suggestions as to where I should look? Thanks for any help.
It's probably bad etiquette to follow up my own email but the response to my earlier email was overwhelming so I assume I didn't give enough information. I did some more digging into my connection drop problem by turning on jabber debugging when the connection does get dropped and I attempt a reconnect. Is this a bug in my code? In REXML? In XMPP4R? In ejabberd? I have a more complete trace but I don't want to flood the list with too much stuff.

Thanks for any help.

Regards,
Spencer
Post by Spencer Cheng
D, [2010-11-23T09:29:50.617561 #8502] DEBUG -- : FEATURES: waiting finished
<stream:features xmlns='jabber:client'><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c node='http://www.process-one.net/en/ejabberd/' hash='sha-1' ver='8P/XuMtKq0lNk50DLBC8v+TXoAU=' xmlns='http://jabber.org/protocol/caps'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features> (REXML::Element)
D, [2010-11-23T09:29:50.618013 #8502] DEBUG -- : TRYING stanzacbs...
D, [2010-11-23T09:29:50.618158 #8502] DEBUG -- : TRYING stanzacbs...
D, [2010-11-23T09:29:50.618372 #8502] DEBUG -- : TRYING message/iq/presence/cbs...
D, [2010-11-23T09:29:50.618562 #8502] DEBUG -- : TRYING message/iq/presence/cbs...
<auth mechanism='DIGEST-MD5' xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
<auth mechanism='DIGEST-MD5' xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
NoMethodError
undefined method `[]' for nil:NilClass
/usr/lib/ruby/1.8/rexml/source.rb:149:in `initialize'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `new'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `create_from'
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream='
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `new'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `initialize'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/streamparser.rb:39:in `new'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/streamparser.rb:39:in `parse'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:75:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `initialize'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `new'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:119:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:87:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:77:in `connect'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:70:in `connect'
/StarCDN/src/xmppclient.rb:81:in `establish_connection'
/StarCDN/src/xmppclient.rb:69:in `connect'
/StarCDN/src/xmppclient.rb:47
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:387:in `call'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:387:in `send'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `initialize'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `new'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:384:in `send'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:79:in `close'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:89:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `initialize'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `new'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:87:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `initialize'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `new'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:72:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:119:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:87:in `start'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:175:in `auth_sasl'
/var/lib/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:110:in `auth'
/StarCDN/src/xmppclient.rb:82:in `establish_connection'
/StarCDN/src/xmppclient.rb:69:in `connect'
/StarCDN/src/xmppclient.rb:51:in `initialize'
/StarCDN/src/xmppclient.rb:286:in `new'
/StarCDN/src/xmppclient.rb:286
Brian Candler
2010-11-29 16:21:23 UTC
Permalink
Post by Spencer Cheng
It's probably bad etiquette to follow up my own email but the response to my earlier email was overwhelming so I assume I didn't give enough information. I did some more digging into my connection drop problem by turning on jabber debugging when the connection does get dropped and I attempt a reconnect. Is this a bug in my code? In REXML? In XMPP4R? In ejabberd? I have a more complete trace but I don't want to flood the list with too much stuff.
...
Post by Spencer Cheng
Post by Spencer Cheng
NoMethodError
undefined method `[]' for nil:NilClass
/usr/lib/ruby/1.8/rexml/source.rb:149:in `initialize'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `new'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `create_from'
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream='
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `new'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `initialize'
What version of ruby are you using? If it's 1.9.x, then I'd try 1.8.7.
Spencer Cheng
2010-11-30 12:55:12 UTC
Permalink
Hi Brian,
Post by Brian Candler
...
Post by Spencer Cheng
NoMethodError
undefined method `[]' for nil:NilClass
/usr/lib/ruby/1.8/rexml/source.rb:149:in `initialize'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `new'
/usr/lib/ruby/1.8/rexml/source.rb:16:in `create_from'
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:133:in `stream='
/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `new'
/usr/lib/ruby/1.8/rexml/parsers/sax2parser.rb:11:in `initialize'
What version of ruby are you using? If it's 1.9.x, then I'd try 1.8.7.
1.8.7 on Ubuntu 10.04. I am a bit behind the times. The xmpp4r gem is up to date. I tried to set a break point using rdebug but it never stops there (I would guess it's because it's deep in the exception handler or some other thread).

Regards,
Spencer

Loading...