使用Smack从ejabberd获取名单在回复超时内未收到任何响应

时间:2017-08-15 03:28:45

标签: android xmpp ejabberd smack

我们的XMPP服务器正在使用Ejabberd。我们有三个客户端连接到聊天应用程序的服务器。它们是IOS,Android和Web。 Web和IOS可以毫无问题地从服务器获取聊天记录。

然而,在Android中,我们无法使用Smack获取消息历史记录。 用户能够通过XMPP连接向服务器发送消息,但它无法接收消息。无论我们设置超时有多大,它总是超时。超时后,服务器将返回结果。

请参阅下面的代码,了解我们如何实施加载聊天记录的代码。

public void loadArchiveMessages(Jid jid, XMPPWebSocketConnection xmppTcpConnection) {
        try {
            MamManager mamManager = MamManager.getInstanceFor(xmppTcpConnection);
            MamManager.MamQueryResult mamQueryResult = mamManager.queryArchive(null, 2, null, null, jid, null);


            List<Forwarded> forwardedMessages = mamQueryResult.forwardedMessages;
            Iterator<Forwarded> forwardedIterator = forwardedMessages.iterator();
            while (forwardedIterator.hasNext()) {
                Forwarded forwarded = forwardedIterator.next();
                Stanza stanza = forwarded.getForwardedStanza();
                if (stanza instanceof org.jivesoftware.smack.packet.Message) {
                    String messageId = stanza.getStanzaId();
                    connection.sendStanzaInternal(stanza);
                }
            }
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (SmackException.NotLoggedInException e) {
            e.printStackTrace();
        } catch (SmackException.NotConnectedException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        }
    }

我们得到的例外情况。

org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 30000ms (~30s). Waited for response using: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=YXCI3-31)), : fromFilter (OrFilter: (FromMatchesFilter (full): otsuka.tungdao.com)).
    08-15 09:15:21.100 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:253)
    08-15 09:15:21.100 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:208)
    08-15 09:15:21.101 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:540)
    08-15 09:15:21.101 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:506)
    08-15 09:15:21.101 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.supportsFeatures(ServiceDiscoveryManager.java:701)
    08-15 09:15:21.101 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeatures(ServiceDiscoveryManager.java:678)
    08-15 09:15:21.101 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeatures(ServiceDiscoveryManager.java:672)
    08-15 09:15:21.102 28911-28945/com.otsuka.android W/System.err:     at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeature(ServiceDiscoveryManager.java:667)

我们试图寻找解决方案但无济于事。

0 个答案:

没有答案