Android SIP registration failed (-9 IN_PROGRESS)
Asked Answered
M

2

8

Here is my registration code:

    protected void initializeManagerOpen(){
    consoleWrite("initializeOpen");
    if(mSipManager==null) {
        return;
    }
    SipProfile.Builder builder;
    try {
        builder = new SipProfile.Builder("13", "10.0.0.4");
        builder.setPassword("13");
        builder.setPort(5062);
        builder.setProtocol("UDP");
        mSipProfile = builder.build();

        try {
            Intent intent = new Intent();
            intent.setAction("android.SipDemo.INCOMING_CALL");
            PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, Intent.FILL_IN_DATA);
            mSipManager.open(mSipProfile, pendingIntent, null);

            mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() {

                public void onRegistering(String localProfileUri) {
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_connecting,"Test","Connecting");

                    consoleWrite("Registering with SIP Server...");
                }

                public void onRegistrationDone(String localProfileUri, long expiryTime){
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_connected,"Test","Connected");

                    consoleWrite("Ready");
                }

                public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage){
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_disconnected,"Test","Failed to connect:"+errorCode);

                    consoleWrite("Registration failed.  Please check settings.");
                    consoleWrite(""+errorCode);
                    consoleWrite(errorMessage);
                }

            });
        } catch (SipException e) {
            e.printStackTrace();
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

Though sometimes it registered successfully, most time I got a error code -9:

Registration failed.  Please check settings.
-9
0

I found this description on reference site:

public static final int IN_PROGRESS
The client is in a transaction and cannot initiate a new one.
Constant Value: -9 (0xfffffff7)

What does it means exactly? I don't have any other SIP application running on my phone.

PS. First time when i am trying to connect, it is working. But second time it returns -9. Maybe i not close connection correctly? I think i have problem because i am trying to close connection but it is not closing...

public void closeLocalProfile() {
    if(mSipManager==null){
        return;
    }
    try{
        if(mSipProfile!=null){
            mSipManager.close(mSipProfile.getUriString());

            consoleWrite("mSipManager Closed - "+mSipProfile.getUriString());
        }
    }catch(Exception e){
        consoleWrite("Failed to close local profile. - "+e);
    }
}
Maracanda answered 15/12, 2013 at 11:43 Comment(6)
Hi ,have you got any solution to this problem???I am also facing the same .Pentamerous
No. I am still working on it.Maracanda
hope you got a solution for that and willing to share it i am having the same problem and started to think about moving to a 3rd party sip libraryBriseno
hi VoW, did you find any soluiton for this problem? I m using nexus 5 my android version is 4.4.4Heterochromous
you reached something?!!Jerrelljerri
@MuhammedRefaat No, still having this problem after 2 years.Maracanda
V
3

Delete all SIP account from Call Parameter and retry :

Call App->Parameter->Call account internet Delete all account

PS: Sorry for the name menu, my phone isn't in english

Veracruz answered 17/9, 2014 at 13:8 Comment(0)
A
1

I've faced the same issue and zicos22's comment helped me to solve it. The problem starts because of unclosed SipProfiles, so you need to run closeLocalProfile() inside onPause() method (it does not work when called inside onDestroy()). Actually, i think i have to run this sip stuff in separate thread, but for now i'm just closing profile in onPause. On my android phone with ZenUI i'am able to close currently opened sip profiles manually in Settings -> Call Settings -> Phone Account Settings -> SIP accounts.

Antonioantonius answered 26/5, 2016 at 4:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.