How to keep a XMPP connection stable on Android with (a)smack?

后端 未结 6 1902
梦毁少年i
梦毁少年i 2020-12-02 18:39

I use asmack-android-7-beem library for Android. I have a background service running, such as my app stays alive. But sooner or later XMPP connection dies without any notice

6条回答
  •  日久生厌
    2020-12-02 19:44

    I have the same problem, except that My program run on server side JVM.
    I used smack 4.0 in the first place. Then I updated to smack 4.1, but the problem still happened. Finally I found a configuration module: PingManager
    After using this, the occurrence of this situation was drop down.

        connection = new XMPPTCPConnection(config);     
        PingManager pingManager = PingManager.getInstanceFor(connection);
        pingManager.setPingInterval(300); // seconds
    

提交回复
热议问题