jdev - 2022-04-22


  1. PapaTutuWawa

    Quick question: Due to reasons I had to implement my own XMPP library for my mobile XMPP client and it works great. However, after some time (unsure about the exact time), my connection just silently stops working and I cannot send or receive data. I don't receive any stream errors; it just stops. This happens although I send pings either by requesting an XEP-0198 ack or by just sending a whitespace ping every 5 minutes. Is there anything else I need to do to stop this from happening?

  2. Ge0rG

    PapaTutuWawa: what platform is your moblie client running on?

  3. PapaTutuWawa

    Android. But the thing is that the system is not killing the app as I keep viewing logs on my PC and I log every ping I send

  4. Zash

    Obscure socket timeout? What does the server logs say?

  5. Ge0rG

    PapaTutuWawa: did you request an exception from battery optimizations?

  6. Ge0rG

    PapaTutuWawa: when you connect the device via USB that might also change power saving behavior

  7. PapaTutuWawa

    Ge0rG: I didn't because I thought that having no exception would just kill the foreground service entirely, which I would notice

  8. PapaTutuWawa

    Zash: I'll have to timeout again, but I think that my prosody just said that the connection timed out

  9. Ge0rG

    PapaTutuWawa: IIRC it will just freeze the app instead

  10. flow

    PapaTutuWawa, do you receive pongs to your xmpp pings?

  11. PapaTutuWawa

    That would still be weird as I can still see the service trying to send a ping to the server even after no data can come in or go out

  12. PapaTutuWawa

    flow: When I used only 0198 pings, then after some point: no. But until then I did. But I still think that 2h at max until I have to reconnect is a bit short, or am I mistaken?

  13. flow

    PapaTutuWawa, i suspect your TCP connection became stale than, could be due to various reasions

  14. flow

    I believe modern Android's even suspend TCP connections of more-or-less inactive non-foreground apps, but it could be also just a middlebox or dozen other things that causes the tcp connection to become stale

  15. PapaTutuWawa

    flow: I didn't know that. I'll try it then

  16. flow

    PapaTutuWawa, try what?

  17. PapaTutuWawa

    Setting a battery optimization exception for my app if it's true that Android suspends TCP connections for inactive apps

  18. PapaTutuWawa

    Sorry for being unclear😅️

  19. flow

    PapaTutuWawa, I doubt that this alone will help

  20. flow

    at least for the latest android versions, which basically force you to use a foreground service for long-lived TCP connections like XMPP uses

  21. flow

    besides that, my recommendation for years has been to act on CONNECTIVITY_CHANGED broadcasts from Android, and have a mechansim to swiftly check if the connection is still alive, based on xep199 pings with a low timeout (say less than 30, 20, or 15 seconds)

  22. flow

    if that check fails, forcefully tear down the XMPP connection and restablish it, ideally using stream mangement

  23. PapaTutuWawa

    It seems like my prosody closes the connection with a "timeout during receiving"