I'm trying to create a multiuser chat with XMPP Smack Api(4.1.4). I've established a login connection using,
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setResource(RESOURCE);
configBuilder.setServiceName(DOMAIN);
configBuilder.setHost(HOST);
XMPPTCPConnection connection = new XMPPTCPConnection(configBuilder.build());
connection.addConnectionListener(connectionListener);
AsyncTask<Void, Void, Boolean> connectionThread = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... arg0) {
try {
connection.connect();
if(connection != null) {
PingManager mPingManager = PingManager.getInstanceFor(connection);
mPingManager.setDefaultPingInterval(1000 * 50);
mPingManager.setPingInterval(1000 * 50);
connection.setPacketReplyTimeout(1000 * 50);
mPingManager.registerPingFailedListener(new PingFailedListener() {
@Override
public void pingFailed() {
// TODO Auto-generated method stub
Log.e("PING", "ping failed");
// AGain Reconnecting code here..
}
});
}
} catch (IOException | SmackException | XMPPException e) {
Log.d(LOCAL_TAG, "connectConnection exc: "+e.getMessage());
}
return null;
}
};
connectionThread.execute();
and it gets connected sucessfully. After connecting, i'm trying to create a group chat using,
try {
SharedPreferences mPreferences = context.getSharedPreferences("App_Pref", Context.MODE_PRIVATE);
String userJid = userJidAddress(with local ip);
String userName = "Test5";
Log.d(LOCAL_TAG, "createGroupChat jid: "+userJid+" -- connection.getServiceName(): "+connection.getServiceName());
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat muc = manager.getMultiUserChat(userJid);
muc.create("InstantRoom");
Log.d(LOCAL_TAG, "createGroupChat -- Group CEATED Successfully ");
Form form = muc.getConfigurationForm();
Form submitForm = form.createAnswerForm();
List<FormField> fields = form.getFields();
Log.d(LOCAL_TAG, "createGroupChat -- fields.size(): "+fields.size());
for (int i = 0; i < fields.size(); i++) {
FormField field = (FormField) fields.get(i);
if (!FormField.Type.hidden.equals(field.getType()) && field.getVariable() != null) {
submitForm.setDefaultAnswer(field.getVariable());
}
}
List owners = new ArrayList();
owners.add("test5"+connection.getServiceName());
owners.add("test7"); //Another user
submitForm.setAnswer("muc#roomconfig_roomowners", owners);
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
muc.sendConfigurationForm(submitForm);
muc.join("InstantRoom");
}
catch(Exception e){
Log.d(LOCAL_TAG, "createGroupChat -- Exception: "+e.toString());
}
But While creating the group, i get an Exception as
"org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 50000ms (~50s). Used filter: AndFilter: (FromMatchesFilter (full): [email protected]/instantroom, StanzaTypeFilter: org.jivesoftware.smack.packet.Presence)."
If i increase the PingIntervals and PacketReplyTimeout milliseconds, then i get a message as
"Thread[5,tid=4403,WaitingInMainSignalCatcherLoop,Thread*=0xb8e933a8,peer=0x12c000a0,"Signal Catcher"]: reacting to signal 3".
without that exception and app set to force close automatically. Hope so, I'm getting the exception at muc.create("InstantRoom") line, because i couldn't get the log after that line. Can anyone help me by figure out what i'm doing wrong and why i'm getting this error and how to proceed after this. Thanks in advance.