2

Here is my registration code:

SipProfile.Builder builder = new SipProfile.Builder(username, ip);
builder.setPort(Integer.parseInt(port));
builder.setPassword(password);
builder.setSendKeepAlive(true);
builder.setAutoRegistration(true);
sipProfile = builder.build();

Intent i = new Intent();
i.setAction(ACTION);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i,
        Intent.FILL_IN_DATA);
sipManager.open(sipProfile, pi, null);
sipManager.setRegistrationListener(sipProfile.getUriString(),
        new SipRegistrationListener() {
            public void onRegistering(String localProfileUri) {
                Log.e("SipService",
                        "Registering with SIP Server...\n"
                                + localProfileUri);
            }

            public void onRegistrationDone(String localProfileUri,
                    long expiryTime) {
                Log.e("SipService", "Ready: " + localProfileUri);
            }

            public void onRegistrationFailed(
                    String localProfileUri, int errorCode,
                    String errorMessage) {
                Log.e("SipService", "Error: " + errorCode + " " + rorMessage);
                Handler handler = new Handler(Looper
                        .getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {

                    Toast.makeText(SipService.this,
                        R.string.sip_registration_error,
                                Toast.LENGTH_LONG).show();
                    }
                });
            }
        });

Though sometimes it registered successfully, most time I got a error code -9:
10-08 14:49:53.389: E/SipService(5793): Error: -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.

Wei-Tsung
  • 297
  • 3
  • 12
  • 1
    hello Leonhart ,have you got the solution ??Me too facing lots of problem with native sip implementation . – Sneha Bansal Dec 23 '13 at 08:20
  • hope you poste the solution if you got it i am having this problem too android is not sending any more regestration packets and returns -9 error code – MolhamStein Aug 21 '14 at 10:24
  • What SIP provider are you registered with? I'm getting the same error when trying to register with my linphone.org account. – mehturt Jun 01 '15 at 15:40
  • any one else seeing this, calling `sipManager.open()` in onResume() instead of onCreate() will solve the issue. – Muhammad Babar Mar 25 '16 at 06:10

1 Answers1

0

I have had what seems to be a similar problem. When using code much like your example based on the official Android SIP tutorial, I was seeing two failed registrations happening at once, one of which gave error -9. Sometimes I also got error -10, DATA_CONNECTION_LOST.

I was able to resolve both by sleeping briefly after creating the Intent:

Intent intent = new Intent();
intent.setAction("my.package.name.INCOMING_CALL");
SystemClock.sleep(1000);
PendingIntent pendingIntent = PendingIntent.getBroadcast(parent, 0, intent, Intent.FILL_IN_DATA);
sipManager.open(mySipProfile, pendingIntent, null);
sipManager.setRegistrationListener(mySipProfile.getUriString(), new SipRegistrationListener() { ... }

As suggested by: SIP:ERROR DATA_CONNECTION_LOST

thejoelpatrol
  • 174
  • 1
  • 7
  • After adding this I get error -3 transaction terminated. Could you please help me how can I resolve this error? – Arjun Feb 10 '21 at 12:55