Android XMPP connection is not persistant - asmack library even running in a separate thread

前端 未结 2 671
闹比i
闹比i 2021-01-15 20:49

I am developing an Android chat app which uses asmack library. What I observe is that the XMPP connection beocmes disconnected after a particular interval of time. ( This al

2条回答
  •  失恋的感觉
    2021-01-15 21:17

    After a long struggle, here are my observations and I was able to find a solution to the issue. Any feedback about my solution is welcome

    The Edit holds the answer.

    I simply modified the code from Runnable to a Thread

    When the code which connects to the chat server was in a Runnable, I got a android.os.NetworkOnMainThreadException. For some reason, I am not able to find the stack trace of NetworkOnMainThreadException. The ConnectionConfiguration was carrying the NetworkOnMainThreadException when the connection is made using a Runnable.

    Hope this helps someone who face a similar issue to mine. I sincerely thank @Flow for his effort in helping me resolve this issue. Your smack work is very commendable and a blessing for the android community.

    See the image attached for the exception. enter image description here

提交回复
热议问题