Smack Openfire Android无法将消息发送到组/房间错误403禁止 [英] Smack Openfire Android Unable to send message to Group/Room Error 403 forbidden

查看:283
本文介绍了Smack Openfire Android无法将消息发送到组/房间错误403禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(xmppconnection.getConnection());
try {
    MultiUserChat muc = manager.getMultiUserChat("test2@conference.cca");

    muc.join("test2@conference.cca");

    Message msg = new Message("test2@conference.cca", Message.Type.groupchat);
    msg.setBody("Hi Testing..Group chat..");
    muc.sendMessage(msg);
    // muc.join("test", "1234");
} catch (SmackException.NotConnectedException e) {
    e.printStackTrace();
} catch (SmackException e) {
    e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
    e.printStackTrace();
} catch (XMPPException e) {
    e.printStackTrace();
}

错误是:

错误代码="403" type ="auth"禁止xmlns ="urn:ietf:params:xml:ns:xmpp-stanzas"/> **

error code="403" type="auth" forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>**

推荐答案

有一些错误,包括逻辑上和过程上的错误.

There are several errors, logical and procedurals.

通过此调用:

 MultiUserChat muc = manager.getMultiUserChat("test2@conference.cca");

您在 muc对象中拥有群聊. 因此,您需要检查您是否已经加入了此群聊,或者双重加入会引发异常.

you have in muc object your groupchat. So you need to check if you already joined this groupchat or double join will raise an exception.

如此

if (!muc.isJoined())
 muc.join("My nickname");

更多,当您加入时,您必须为每个用户提供唯一的昵称才能加入,否则您将获得第二个用户的例外.将昵称设置为群组聊天的昵称,这是99%的逻辑错误.

more, when you join, you MUST provide an unique nickname per User to join, or you'll obtain an exception with the second user. Set as nickname the same name of the groupchat it's 99% a logical error.

最后,要发送一条消息,只需通过MUC对象发送它,否则像这种情况,您将冒着丢失一些信息的风险.

Finally, to send a message, just send it through MUC object or you'll risk, like in this case, to miss some information.

所以只需发送

muc.send("Hi Testing..Group chat..");

最后但并非最不重要的一点:当然,必须正确存在或初始化多用户聊天,这是完成所有这些操作的先决条件.第一步,只需在Openfire中使用http-admin-panel创建它(使其持久)

Last but not least: of course multiuserchat must exists or inititilized before properly, it's a prerequisite to do all this. As first step, just create it in Openfire with http-admin-panel (make it persistant)

这篇关于Smack Openfire Android无法将消息发送到组/房间错误403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆