Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 获得;XMPPException$XMPPError异常:XMPPError:服务不可用-取消";使用XMPP创建组时(4.1.3)_Android_Xmpp_Ejabberd_Asmack - Fatal编程技术网

Android 获得;XMPPException$XMPPError异常:XMPPError:服务不可用-取消";使用XMPP创建组时(4.1.3)

Android 获得;XMPPException$XMPPError异常:XMPPError:服务不可用-取消";使用XMPP创建组时(4.1.3),android,xmpp,ejabberd,asmack,Android,Xmpp,Ejabberd,Asmack,我在使用XMPP(4.1.3)创建聊天组时遇到了一个问题 我的代码是 try{ // Get the MultiUserChatManager MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(ClosrrService.xmppConnection); Log.e("Connection : ", ClosrrServi

我在使用XMPP(4.1.3)创建聊天组时遇到了一个问题

我的代码是

       try{

            // Get the MultiUserChatManager
            MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(ClosrrService.xmppConnection);

            Log.e("Connection  : ", ClosrrService.xmppConnection.toString());

            // Get a MultiUserChat using MultiUserChatManager
            MultiUserChat muc = manager.getMultiUserChat("dayaroom@conference."+Constants.HOST);

            // Create the room and send an empty configuration form to make this an instant room
            muc.create("testbotdaya");

            muc.sendConfigurationForm(new Form(DataForm.Type.submit));


        }catch (Exception e) {
            e.printStackTrace();
        }
在上面的代码中,我在
muc.create(“testbotdaya”)上遇到异常和异常是

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: service-unavailable - cancel
 W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
 W/System.err﹕ at org.jivesoftware.smackx.muc.MultiUserChat.enter(MultiUserChat.java:311)
 W/System.err﹕ at org.jivesoftware.smackx.muc.MultiUserChat.createOrJoin(MultiUserChat.java:400)
 at org.jivesoftware.smackx.muc.MultiUserChat.createOrJoin(MultiUserChat.java:376)
 W/System.err﹕ at org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:354)
 W/System.err﹕ at com.rappier.closrr.chat.grpupchat.CreateGroupActivity.createGroup(CreateGroupActivity.java:82)
 W/System.err﹕ at com.rappier.closrr.chat.grpupchat.CreateGroupActivity.onClick(CreateGroupActivity.java:64)

请帮帮我。提前感谢。

我也遇到了同样的问题,但经过大量研究,我找到了解决办法

这是我正在使用的创建组方法,我检查您的代码,请与我的代码进行比较,以便您可以找到错误

public boolean createGroup() {
    try {
        String myJid = "MY_JID";
        String grp_name = "TestGroup";

        //creating unique group id using
        String groupId = grp_name.toLowerCase() + "_" + String.valueOf(System.currentTimeMillis() / 1000L);

        //this list for send invitations if you need.
        ArrayList<String> friendList = new ArrayList<>();
        friendList.add("friendNameJID1");
        friendList.add("friendNameJID2");
        friendList.add("friendNameJID3");


        if (TextUtils.isEmpty(grp_name) || TextUtils.isEmpty(groupId)) {
            return false;
        }

        // Create the XMPP address (JID) of the MUC.
        EntityBareJid mucJid = JidCreate.entityBareFrom(groupId + "@conference.localhost");//groupId@conference.domain name
        // Create the nickname.
        Resourcepart nickname = Resourcepart.from(myJid);
        // Get the MultiUserChatManager
        MultiUserChatManager mucChatManager = MultiUserChatManager.getInstanceFor(MyApplication.connection);
        // Get a MultiUserChat using MultiUserChatManager
        MultiUserChat mucChat = mucChatManager.getMultiUserChat(mucJid);


        try {

            // Create the room
            mucChat.create(nickname);


            Form form = mucChat.getConfigurationForm();
            Form submitForm = form.createAnswerForm();

            for (FormField formField : submitForm.getFields()) {

                if (!FormField.Type.hidden.equals(formField.getType())
                        && formField.getVariable() != null) {
                    submitForm.setDefaultAnswer(formField.getVariable());
                }
            }


            submitForm.setAnswer("muc#roomconfig_publicroom", true);
            submitForm.setAnswer("muc#roomconfig_persistentroom", true);
            submitForm.setAnswer("muc#roomconfig_roomname", grp_name);


            mucChat.sendConfigurationForm(submitForm);

            mucChat.join(nickname);

            for (String names : friendList) {

                Message message = new Message();
                // message.setType(Type.normal);  //optional
                message.setSubject(Constants.GROUP_CHAT_MSG_MODE);
                message.setBody(Constants.GROUP_GREETINGS);

                EntityBareJid eJId = JidCreate.entityBareFrom(names + "@" + Constants.XMPP_DOMAIN);
                mucChat.invite(message, eJId, groupId);

            }

            return true;

        } catch (MultiUserChatException.MissingMucCreationAcknowledgeException e) {

            Log.d(TAG, "Group is already there " + Arrays.toString(e.getStackTrace()));
            return false;
        } catch (MultiUserChatException.MucAlreadyJoinedException e) {

            Log.d(TAG, "Group Error : " + e.getMessage());
            return false;
        }

    } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | XmppStringprepException | MultiUserChatException.NotAMucServiceException e) {
        Log.d(TAG, "Group Error : " + e.getMessage());
        return false;
    } catch (SmackException.NotConnectedException e) {
        Log.d(TAG, "Group Error : " + e.getMessage());
        return false;
    }
}
public boolean createGroup(){
试一试{
String myJid=“MY_JID”;
字符串grp_name=“TestGroup”;
//使用创建唯一的组id
String groupId=grp_name.toLowerCase()+“”+String.valueOf(System.currentTimeMillis()/1000L);
//此列表用于在需要时发送邀请。
ArrayList friendList=新建ArrayList();
friendList.添加(“friendNameJID1”);
添加(“friendNameJID2”);
添加(“friendNameJID3”);
if(TextUtils.isEmpty(grp_name)| | TextUtils.isEmpty(groupId)){
返回false;
}
//创建MUC的XMPP地址(JID)。
EntityBareJid mucJid=JidCreate.entityBareFrom(groupId+“@conference.localhost”)//groupId@conference.domain名称
//创建昵称。
Resourcepart昵称=Resourcepart.from(myJid);
//获取多用户聊天管理器
MultiUserChatManager mucChatManager=MultiUserChatManager.getInstanceFor(MyApplication.connection);
//使用MultiUserChatManager获取MultiUserChat
MultiUserChat mucChat=mucChatManager.getMultiUserChat(mucJid);
试一试{
//创建房间
mucChat.create(昵称);
Form Form=mucChat.getConfigurationForm();
Form submitForm=Form.createAnswerForm();
for(FormField FormField:submitForm.getFields()){
如果(!FormField.Type.hidden.equals)(FormField.getType())
&&formField.getVariable()!=null){
submitForm.setDefaultAnswer(formField.getVariable());
}
}
submitForm.setAnswer(“muc#roomconfig_publicroom”,true);
submitForm.setAnswer(“muc#roomconfig_persistentroom”,true);
submitForm.setAnswer(“muc#roomconfig_roomname”,grp_name);
mucChat.sendConfigurationForm(submitForm);
mucChat.join(昵称);
for(字符串名称:friendList){
消息消息=新消息();
//message.setType(Type.normal);//可选
message.setSubject(常量.GROUP\u CHAT\u MSG\u模式);
message.setBody(Constants.GROUP_问候语);
EntityBareJid eJId=JidCreate.entityBareFrom(名称+“@”+常量.XMPP_域);
邀请(message、eJId、groupId);
}
返回true;
}捕获(MultiUserChatException.MissingMucCreationAcknowledgeeException e){
Log.d(标记“组已经存在”+Arrays.toString(例如getStackTrace());
返回false;
}捕获(MultiUserChatException.MucAlreadyJoinedException e){
Log.d(标记,“组错误:+e.getMessage());
返回false;
}
}捕获(smakeException.NoResponseException | xmppeException.XMPPErrorException | InterruptedException | xmppstringpreception | MultiUserChatException.notamcserviceException e){
Log.d(标记,“组错误:+e.getMessage());
返回false;
}捕捉(SmackException.NotConnectedException e){
Log.d(标记,“组错误:+e.getMessage());
返回false;
}
}

如果您有任何解决方案,请通知我是否有相同的错误