我一遍又一遍地收到同样的错误信息。起初我认为这是一个超时的问题所以我设置.setPacketReplyTimeout(15000);
仍然只是等待更长时间然后显示相同的错误消息。在更深入的调查结果中,我发现这是因为它期待服务器的某些东西(可能是什么?)。我还发现,你可以setRosterLoadedAtLogin(false)
,但不清楚如何,因为XMPPTCPConnectionConfiguration
没有那种方法,即configBuilder.setRosterLoadedAtLogin(false)
。这是一个转储。我想要了解正在发生的事情以及如何解决这个问题。谢谢
06-09 01:04:25.122 3192-3214/com.company.smacklearn E/Roster﹕ Exception reloading roster
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=AUQtk-7)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (bare): user@myserver.com, FromMatchesFilter (full): myserver.com)).
at org.jivesoftware.smack.AbstractXMPPConnection$6.run(AbstractXMPPConnection.java:1438)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
答案 0 :(得分:0)
这是我的转储:
07-07 18:06:31.469 7218-7260/cc.lait.d2.smack_demo E/Roster﹕ Exception reloading roster
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=s3Dmr-7)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (bare): e02b65a7bdc0f12662ac0d617e7eb3d1@iz23qr9ipxwz, FromMatchesFilter (full): iz23qr9ipxwz)).
at org.jivesoftware.smack.AbstractXMPPConnection$6.run(AbstractXMPPConnection.java:1438)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
我最近几天也开始使用smack4.1,遇到了类似的错误,进行了测试,因为我使用con.disconnect();
。在smack 4.1中,我们找不到setRosterLoadedAtLogin()
,所以我认为我们关闭连接的时间是错误的。
答案 1 :(得分:-1)
@Override
protected void onDestroy() {
super.onDestroy();
con.disconnect();
}
我发现,如果我们在con.disconnect();
或onDestroy()
中使用onPause()
,则不会收到错误Exception reloading roster
答案 2 :(得分:-1)
也许我在以下代码的项目中找到了正确操作的真正原因:
try {
ConnectionConfiguration config = new ConnectionConfiguration(OF_HOST, OF_PORT);
config.setReconnectionAllowed(true);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setSendPresence(true);
config.setDebuggerEnabled(true);
config.setCompressionEnabled(false);
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection = new XMPPTCPConnection(config);
Log.i("connection", connection.toString());
if (connection.isConnected()) {
connection.disconnect();
}
connection.connect();
return connection;
} catch (Exception e) {
e.printStackTrace();
}