Android SipManager: android.net.sip.SipException: SipService.createSession () returns null

So, I have been coding this Android Sip application using the Androids Sip library for some time, but I cannot get the registration to work. It currently causes the following error when I call SipManager.register() : android.net.sip.SipException: SipService.createSession() returns null .

My code is:

 public static void Register(final String username, final String password, final String domain, final String cbf) throws ParseException, SipException { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register"); /* * Luodaan SIP-profiili */ SipProfile.Builder builder = new SipProfile.Builder(username, domain); builder.setPassword(password); //builder.setProtocol("TCP"); //builder.setPort(5060); builder.setAutoRegistration(false); _sipprofile = builder.build(); Intent intent = new Intent(); intent.setAction("android.jahtipuhelin.INCOMING_CALL"); PendingIntent pendingIntent = PendingIntent.getBroadcast(_context, 0, intent, Intent.FILL_IN_DATA); _sipmanager.open(_sipprofile, pendingIntent, new SipRegistrationListener() { @Override public void onRegistering(String s) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 0"); } @Override public void onRegistrationDone(String s, long l) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 1"); try { _sipmanager.register(_sipprofile, 30, null); _sipmanager.setRegistrationListener(_sipprofile.getUriString(), new JPSipRegistrationListener(_class, cbf)); } catch (SipException e) { Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage()); e.printStackTrace(); } } @Override public void onRegistrationFailed(String s, int i, String s2) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 2"); Log.d(MainActivity.LOGTAG, s2); try { _sipmanager.register(_sipprofile, 30, null); _sipmanager.setRegistrationListener(_sipprofile.getUriString(), new JPSipRegistrationListener(_class, cbf)); } catch (SipException e) { Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage()); e.printStackTrace(); } } });//*/ Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - 2"); } private static class JPSipRegistrationListener implements SipRegistrationListener { private MainActivity _parent; private String _callBack; public JPSipRegistrationListener(MainActivity ma, String callBack) { this._parent = ma; this._callBack = callBack; } @Override public void onRegistering(String localProfileUri) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistering"); _parent.callSub(_callBack, REGISTERING, 0, ""); } @Override public void onRegistrationDone(String localProfileUri, long expiryTime) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationDone"); _parent.callSub(_callBack, REGISTRATION_DONE, 0, ""); } @Override public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationFailed"); Log.e(MainActivity.LOGTAG, "Virhe Sip-rekisteröinnissä: "+errorCode+": "+errorMessage); if (errorCode == -10) { return; } _parent.callSub(_callBack, REGISTRATION_FAILED, errorCode, errorMessage); } } 

A run that gives the following output:

 08-11 18:50:58.276 24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register 08-11 18:50:58.436 24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - testi 2 08-11 18:50:58.436 24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: registration not running 08-11 18:50:58.446 24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - 2 08-11 18:50:58.666 24449-24465/fi.hieta.aatu.android.jahtipuhelin E/fi.hieta.aatu.android.jahtipuhelin: class android.net.sip.SipException: SipService.createSession() returns null 

Does anyone know what I'm doing wrong here? Also, I am trying to manually register the sip profile, rather than using auto-registration. (By the way, my first question is about stackoverflow, so please be careful :))

+7
java android sip
source share
2 answers

There seems to be at least one other quirk leading up to the same error code. If you have a predefined account with the same request URI on your phone, the second method that you are trying to create in your application fails in this way. Please note that this happens even if this account is not set for incoming calls (= SIP Register in the backend). I hope that the Android team will fix this error or at least produce a meaningful error.

+5
source share

Update: An exception was thrown with this solution, but I could not get the calls.

I have found a solution. Before calling the register, you must open the call. Also, don't use an open listener (SipDemo says so, not sure why), but register it after registration (works for me).

So my code is:

 manager.open(localProfile, pendingIntent, null); manager.register(localProfile, 20, listener); manager.setRegistrationListener(localProfile.getUriString(), listener); 
+4
source share

All Articles