加入会议时无响应 SmackException NoResponseException

No response while joining conference SmackException NoResponseException

我在加入会议聊天时遇到异常。

异常:

org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Waited for response using: AndFilter: (StanzaTypeFilter: Presence, OrFilter: (AndFilter: (FromMatchesFilter (ignoreResourcepart): hdhd@conference.35.171.18.126, MUCUserStatusCodeFilter: status=110), AndFilter: (FromMatchesFilter (full): hdhd@conference.35.171.18.126/user00000003, StanzaIdFilter: id=c3v5j-70, PresenceTypeFilter: type=error))). 07-02 12:39:58.019 31567-31567/com.br.granplay W/System.err: at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:260)

代码:

muc = MucManager.getInstance()
                        .getMultiUserChat(MucManager.getEntityBareJid(jid));
                String strresource = XmppConnection.getXMPPConnction()
                        .getUser().getLocalpart().toString();
                Resourcepart resourcepart = Resourcepart.from(strresource);
                MucEnterConfiguration.Builder mec = muc.getEnterConfigurationBuilder(
                       resourcepart);

                mec.requestNoHistory();
                MucEnterConfiguration mucEnterConfig = mec.build();
                muc.join(mucEnterConfig);
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout

通常,当用户的状态未更新到 Openfire 服务器并尝试加入房间时,会出现此异常。

因此请在关闭应用程序时在 onStop() 上更新您的在线状态(不可用)。 并在 Resume() 上设置你的状态(可用)。

仍然,您会收到此异常,然后在出现异常时将用户状态 "Unavailable" 发送到 Openfire 服务器,并在 1-2 秒后发送状态 "Available",然后加入群组。

我在修复之前使用以下配置进行 xmpp 连接。

 XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
                .setXmppDomain(mServiceName)
                .setHostAddress(getIpAddressOrNull(mServiceName))
                .setResource("Android")
                .setUsernameAndPassword(mUsername, mPassword) 
                .setKeystoreType(null) //This line seems to get rid of the problem
                .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                .setCompressionEnabled(true)
                .setSendPresence(true)
                .setDebuggerEnabled(false)
                .build();

删除资源部分后问题已解决。

.setResource("Android")