Skip to content Skip to sidebar Skip to footer

Quickblox One To One Chat Connection Lost

I have developed chat application using Quickblox SDK version 0.8.1. Sometimes app loses chat connection to the server so can not send message or receive message even in same chat

Solution 1:

To reconnect to Chat please do:

iOS way

- (void)chatDidFailWithError:(int)code
{
    // reconnect[[QBChat instance] loginWithUser:[LocalStorageController shared].qbUser];
}

Android way (SDK 1.1 version)

// initialize SMACKSmackAndroid.init(this);

final QBUser user = newQBUser("garry", "garry2892pass");
user.setId(4234);
QBChatService.getInstance().loginWithUser(user, LoginActivity.this);


@OverridepublicvoidonLoginSuccess() {
    Log.d(TAG, "success when login");
}

@OverridepublicvoidonLoginError() {
    Log.e(TAG, "error when login");
}

@OverridepublicvoidonDisconnect() {
    Log.d(TAG, "disconnect when login");

    // Relogin here
}

@OverridepublicvoidonDisconnectOnError(Exception exc) {
    Log.e(TAG, "disconnect error when login", exc);

    // Relogin here
}

More info here http://quickblox.com/developers/Android_XMPP_Chat_Sample

Just update Android SDK to 1.1 here http://quickblox.com/developers/Android#Download_Android_SDK

Solution 2:

Use latest version of quickblox. Current version is 1.1.

You have to send presence after login with timeer according to this documentation. http://quickblox.com/developers/Android_XMPP_Chat_Sample

After login

QBChatService.getInstance().startAutoSendPresence(60);

Hope this will solve.

Solution 3:

Use this way when using Quickblox SDK 2.0

ConnectionListener connectionListener = newConnectionListener() {
@Overridepublicvoidconnected(XMPPConnection connection) {

}

@Overridepublicvoidauthenticated(XMPPConnection connection) {

}

@OverridepublicvoidconnectionClosed() {

}

@OverridepublicvoidconnectionClosedOnError(Exception e) {
    // connection closed on error. It will be established soon
}

@OverridepublicvoidreconnectingIn(int seconds) {

}

@OverridepublicvoidreconnectionSuccessful() {

}

@OverridepublicvoidreconnectionFailed(Exception e) {

}
};



QBChatService.getInstance().addConnectionListener(connectionListener);

Post a Comment for "Quickblox One To One Chat Connection Lost"