PapaTutuWawaQuick 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?
Ge0rGPapaTutuWawa: what platform is your moblie client running on?
PapaTutuWawaAndroid. 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
ZashObscure socket timeout? What does the server logs say?
Ge0rGPapaTutuWawa: did you request an exception from battery optimizations?
Ge0rGPapaTutuWawa: when you connect the device via USB that might also change power saving behavior
PapaTutuWawaGe0rG: I didn't because I thought that having no exception would just kill the foreground service entirely, which I would notice
PapaTutuWawaZash: I'll have to timeout again, but I think that my prosody just said that the connection timed out
Ge0rGPapaTutuWawa: IIRC it will just freeze the app instead
flowPapaTutuWawa, do you receive pongs to your xmpp pings?
PapaTutuWawaThat 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
PapaTutuWawaflow: 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?
flowPapaTutuWawa, i suspect your TCP connection became stale than, could be due to various reasions
flowI 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
PapaTutuWawaflow: I didn't know that. I'll try it then
flowPapaTutuWawa, try what?
PapaTutuWawaSetting a battery optimization exception for my app if it's true that Android suspends TCP connections for inactive apps
PapaTutuWawaSorry for being unclear😅️
flowPapaTutuWawa, I doubt that this alone will help
flowat least for the latest android versions, which basically force you to use a foreground service for long-lived TCP connections like XMPP uses
flowbesides 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)
flowif that check fails, forcefully tear down the XMPP connection and restablish it, ideally using stream mangement
PapaTutuWawaIt seems like my prosody closes the connection with a "timeout during receiving"