crewshin
crewshin

Reputation: 775

Ejabberd server keeps logging me off and back on constantly

I'm building an iOS app, but the problem exists on all clients. iChat, Messages, Psi, etc. So because it exists on all clients I'm going to assume it's a server issue.

Has anyone ever experienced something like this? If so, what did you do to fix it? I'm sure it's some silly config setting or something but I simply can't figure this out. This is the only thing that looks like it might be related in ejabberd.log:

=ERROR REPORT==== 2012-09-05 12:07:12 ===
Mnesia(ejabberd@localhost): ** WARNING ** Mnesia is overloaded: {dump_log,
                                                             time_threshold}

Thanks in advance for any tips/pointers.

Upvotes: 2

Views: 3383

Answers (3)

David Laban
David Laban

Reputation: 36

https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L936 seems to have already been patched. The config variable is called resource_conflict and the value you want is setresource.

Upvotes: 2

Abhinav Singh
Abhinav Singh

Reputation: 2651

The above warning is (probably) not related to the issue you are facing. These mnesia events usually happens when the transaction log needs to be dumped, but the previous transaction log dump hasn't finished yet.

Problem that you are facing needs to be debugged for which you can set {log_level, 5} inside ejabberd.cfg. This will enable debug logging for ejabberd. Then look into the logs to find any guesses on why this is happening for you. Also, come back and paste your log file details here, probably we will be able to help you further. I have never faced such non-sensical issues with ejabberd.

Update after log file attachment:

As Joe wrote below, this is indeed happening because of resource conflict. Two of your clients are trying to login with same resource value. But in an ideal world this shouldn't matter. Jabber servers SHOULD take care of this by appending or prepending custom value on top of resource value requested by the client.

For example, here is what gtalk (even facebook chat) servers will do:

SENT <iq xmlns="jabber:client" type="set" id="1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>jaxl#resource</resource></bind></iq>
RCVD <iq id="1" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>[email protected]/jaxl#resou27F46704</jid></bind></iq>

As you can see my client requested to bind with resource value jaxl#resource but gtalk server actually bound my session with resource value jaxl#resou27F46704. In short, this is not a bug in your client but a bug in ejabberd.

To fix this you can do two things:

  1. Resource value is probably hardcoded somewhere in your client configuration. Simply remove that. A good client will automatically take care of this by generating a random resource value at it's end.
  2. Patch ejabberd to behave how gtalk server does (as shown above). This is the relevant section inside ejabberd_c2s.erl src which needs some tweaking. Also search for Replaced by new connection inside the c2s source file and you will understand what's going on.

Upvotes: 2

Joe Hildebrand
Joe Hildebrand

Reputation: 10414

This sounds like the "dueling resources" bug in your client. You may have two copies of your client running simultaneously using the same resource, and doing faulty auto-reconnect logic. When the second client logs in, the first client is booted offline with a conflict error. The first client logs back in, causing a conflict error on the second client. Loop.

Evidence for this is in your logfile, on line 3480:

D(<0.373.0>:ejabberd_c2s:1553) : Send XML on stream = 
  <<"<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
       <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
         Replaced by new connection
       </text>
     </stream:error>">>

Upvotes: 1

Related Questions