ReconnectionManager in asmack

可紊 提交于 2019-11-30 15:40:19

Use the latest smack api - I am using 4.1.0

Then set up re-connection like below:

ReconnectionManager manager = ReconnectionManager.getInstanceFor(connection);
manager.enableAutomaticReconnection();

It will automatically re-connect as described Here

Asmack is supporting Re-connection properly, only problem is that You are using SASL Connection so this is giving problem for because you are trying same connection again on turn Wi-Fi off.Try with set SASL false

connConfig.setSASLAuthenticationEnabled(false);

required other wise disconnect manually

connection.disconnect();

When setting up everything at the start, call

ReconnectionManager.setEnabledPerDefault(true);

Then connections created from then on will automatically reconnect.

Don't use reconnection mechanism which is implemented in ASMACK.

Use:

    connConfig.setReconnectionAllowed(false);

Instead, you should create BroadcastReceiver which listens to ConnectivityManager.CONNECTIVITY_ACTION. When connection to WIFI or other network is occurred, then you will receive the callback onReceive in your BroadcastReceiver.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!