The only way I see to detect broken connection (besides using PingManager, which is not available on the server) is to check that the stanza has been acknowledged (with SM) in time. Unfortunately, I have no listener to detect sending requests <r xmlns = 'urn: xmpp: sm: 3' />, which are automatically sent by the lib ? How could I detect a request that was not acknowledged?
Every XMPP compliant server responds to XMPP pings.
You should never find yourself in a situation where you need to detect that a SM request was not acknowledged. If you want to check if your connection is alive, use PingManager.pingMyServer().
Unless I’m mistaken, it’s not write in the RFC that ping support is required.
Besides in the rfc, it’s indicated that it’s possible to check that the connection is still alive with SM.
In our app, we need to quickly detect that the connection has been broken. Usign SM rather than Ping would allow us to detect faster than a message wasn’t sent because we can’t send a ping after each message to avoid overloading the server
That is right. But it is written in the RFC that every IQ request must be answered.
Actually the RFC says quite the opposite
If the underlying TCP connection is dead, stream-level checks (e.g., [XEP-0199] and [XEP-0198]) are ineffective.
(emphasis mine)
You can not detect it faster with SM. And, if anything, SM requests are more expensive, in terms of computational power, to handle by the server than pings.
tl;dr: Use XEP-0198 Pings to detect if the connection is still alive.