title: ejabberd online status when user loses connection
body: <p>I have ejabberd setup to be the xmpp server between mobile apps, ie. custom iPhone and Android app.</p>
  
  <p>But I've seemingly run into a limitation of the way ejabberd handles online status's.</p>
  
  <p>Scenario:</p>
  
  <ul>
  <li>User A is messaging User B via their mobiles.</li>
  <li>User B loses all connectivity, so client can't disconnect from server. </li>
  <li>ejabberd still lists User B as online.</li>
  <li>Since ejabberd assumes User B is still online, any message from User A gets passed on to the dead connection.</li>
  <li>So user B won't get the message, nor does it get saved as an offline message, as ejabberd assumes the user is online.</li>
  <li>Message lost. </li>
  <li>Until ejabberd realises that the connection is stale, it treats it as an online user.</li>
  </ul>
  
  <p>And throw in data connection changes (wifi to 3G to 4G to...) and you'll find this happening quite a lot.</p>
  
  <p>mod_ping:</p>
  
  <p>I tried to implement mod_ping on a 10 second interval.<br>
  <a href="https://www.process-one.net/docs/ejabberd/guide_en.html#modping">https://www.process-one.net/docs/ejabberd/guide_en.html#modping</a>
  <br>But as the documentation states, the ping will wait 32 seconds for a response before disconnecting the user.
  <br>This means there will be a 42 second window where the user can lose their messages.</p>
  
  <p>Ideal Solution:</p>
  
  <p>Even if the ping wait time could be reduce, it's still not a perfect solution.
  <br>Is there a way that ejabberd can wait for a 200 response from the client before discarding the message? If no response then save it offline.
  <br>Is it possible to write a hook to solve this problem?
  <br>Or is there a simple setting I've missed somewhere?</p>
  
  <p>FYI: I am not using BOSH.</p>