Skip to content Skip to sidebar Skip to footer

Sip:error Data_connection_lost

I have created sip application using native sip in android .In it I am getting problem in unregistering account from sip server and every time I am getting DATA_CONNECTION_LOST .I

Solution 1:

I've been checking SipDemo sample code, the one I assume you used as reference for your application, an also faced this error but with registration process.

After checking Android's source code (4.1), I saw this is a bug in stack's implementation. More in detail:

  1. SIP services registers and Intend listener for updating connection information.
  2. When you try to register an SipRegistrationListener too fast (by using setRegistrationListener), as network info hasn't been updated (no intent has been received), it returns SipErrorCode.DATA_CONNECTION_LOST, but, actually, session is finally properly registered.

In you case, as you're providing SipRegistrationListener in unregister method, this process fails. An ugly work around would be wait some time for intent to be received or don't provide the listener.

You will also see that, if you replace unregister call by setRegistrationLister you will still receive same error so, something you can also try is create an upper management, this is, in onRegistrationDone callback, you can set a flag to know if you can close or not the profile. Something like:

publicvoidupdateStatus(finalint status, final Context context) {
    if(status == STATUS_OK)
        registered = true;

    // Be a good citizen.  Make sure UI changes fire on the UI thread.this.runOnUiThread(newRunnable() {
        publicvoidrun() {
            generateNotification(context, statusToString(status));
        }
    });
}

and, when closing local profile:

publicBoolean closeLocalProfile() {
    Log.e("Closing profile", "closing profile " + me.getUriString());

    if (manager == null || !registered) {
        returnfalse;
    }
    try {
        if (me != null) {
            Log.e("Unregistering profile", "Un registering profile ");
            manager.unregister(me, null);
            manager.close(me.getUriString());
        }
    } catch (Exception ee) {
        Log.d("WalkieTalkieActivity/onDestroy", "Failed to close local profile.", ee);
    }
    returnfalse;
}

Please note that I used an integer in updateStatus instead of a string and used a helper function, statusToString to translate status codes to strings.

As you probably noted, this would add an extra management layer that, initially, should already be in the stack but it's not. I'm not really sure this would fix all return errors (after checking source code I saw several possible errors), but should help.

Post a Comment for "Sip:error Data_connection_lost"