1.连接之前静态加载 ReconnectionManager static {try {Class.forName("org.jivesoftware.smack.ReconnectionManager");//org.jivesoftware.smack.ReconnectionManager} catch (Exception e) {e.printStackTrace();} }
2.连接之后,开始设置重连,及自定义重连间隔
//默认重连间隔策略是随机15毫秒,下面是自定义间隔时间,需要设置连接策略 //ReconnectionManager.setDefaultReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);ReconnectionManager.setDefaultFixedDelay(50);ReconnectionManager.setEnabledPerDefault(true);//自动重连