Android Question [SOLVED] SIP Failed, ErrorCode=-9, Message=0

AHilberink

Active Member
Licensed User
Longtime User
Hi,

Using the SIP library, I got the error code: Failed, ErrorCode=-9, Message=0
The account is brand new, never used on other devices.

I tried several Initialize and port options, but no result.
I see the Event SIP_Registering is never fired.
Calling my provider gives the answer "no logs", so I never reach him.

I use the example of Erel:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    rp.CheckAndRequest(rp.PERMISSION_USE_SIP)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        ToastMessageShow("No permission!", True)
        Activity.Finish
    End If
   
    If Sip.IsInitialized = False Then
        'Check if SIP and VOIP are supported.
        If Sip.IsSipSupported = False Or Sip.IsVoipSupported = False Then
            Log("Not supported.")
            ToastMessageShow("SIP not supported.", True)
        Else
            'Register with the VOIP service
            Sip.Initialize2("SIP", "sip:[email protected]", "xxxx")
            'Sip.Initialize("Sip","xxxx","xx.xxx.xx.xx","xxxx")
            Sip.OutboundProxy="xx.xxx.xx.xx"
            Sip.Port=5060
            Sip.Register
        End If
    End If
    Activity.LoadLayout("1")
End Sub

Is there something to check?
My URI has it's domain, but my registration server is another IP. It is a Generic. Could this be a cause?

Kind regards,
André
 
Last edited:

AHilberink

Active Member
Licensed User
Longtime User
-9 = https://developer.android.com/reference/android/net/sip/SipErrorCode#IN_PROGRESS

Maybe the SIP feature is locked by a different app. Try to restart the device.

Tried on my samsung tablet. This works, but I got a 403 at the server side and a -3 Communication terminated at tablet side.
Username/password error.

I am not shure how I have to Initialize the SIP.
I have an URI like: sip:[email protected]
I have an loginname like: UA1234567
I have a password
I have a Registrationserver like: xxx.xxx.xxx.xxx

How do I Initialize?
SIP.Initialize has possibility to give username, but because loginname and URI-username is different I did not got it work
SIP.Initialize2 has possibility to use URI but no username

I use the Outboundproxy as Registrationserver.

Can someone tell me the rigth way to register?

Kind regards,
André
 
Last edited:
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Could it be something to do with: setAuthUserName(java.lang.String)

Added since api12 and not in library?
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
No. It will take the User value passed in the Initialize method.

But the Userlogin value of the intialize methode is different from the Authentication value in my case.
URI= [email protected]
AuthenticationID= UA123456

Using an universal sip softphone I have userloginname as a setting and also an authenticationid as a setting. Than my registering is succesfull.

Is it possible to set these parameters seperate from eachother using the library v1.00?
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
B4X:
Dim r As Reflector
r.Target = SIP
Dim builder As JavaObject = r.GetField("builder")
builder.RunMethod("setAuthUserName", Array("UA123456"))

I don not get it to work. I think my SIP provider (Broadsoft) will not work with the native SIP of android ☹
The registering is be done by 2way registration. The first is cancel by a 403 authentication error .
Frustrating while a common Softphone from Playstore is working

I need to look for another solution.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
I am still not convience it is not possible.

An image on internet of Android 6 of the accountsettings of the default phone tells me it should be possible:
Knipsel.JPG


I can see an Username and an Authentication username.

Can I made these setting with the library?

I now use these settings:
B4X:
            'Register with the VOIP service
            Sip.Initialize("SIP","U123456","xxxx.nl","xxxxxxx")
            Dim r As Reflector
            r.Target = Sip
            Dim builder As JavaObject = r.GetField("builder")
            builder.RunMethod("setAuthUserName", Array("UA123456"))
            Sip.OutboundProxy="xx.xxx.xx.xx"
            Sip.Port=5060
            Sip.Register

Kind regards,
André
 
Last edited:
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Once you get the builder JavaObject, you can call any method you like: https://developer.android.com/reference/android/net/sip/SipProfile.Builder

Thank you for this. I succeed to set the profile using your method example before. I don't know how to set a constructor.
I have no experiance with using JavaObject and Reflectors so I am not able to translate the SDK information of the android developer site.
Can you please help me with an example?

I am familiar with C# and I have to do something like:
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setAuthUserName("UA123456")
builder.setPassword(password);


but I do not know how to translate this to B4A.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Try exactly what Erel showed on post #7 above.
For password you add line
B4X:
builder.RunMethod("setPassword", Array("MyPassword"))
You can do the same with the other static methods from the link on Adroid Developers' page.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Thank you for this. I succeed to set the profile using your method example before. I don't know how to set a constructor.
I have no experiance with using JavaObject and Reflectors so I am not able to translate the SDK information of the android developer site.
Can you please help me with an example?

I am familiar with C# and I have to do something like:
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setAuthUserName("UA123456")
builder.setPassword(password);


but I do not know how to translate this to B4A.

Forget this question. After a restart of both my devices (Samsung TabA and Moto G8Plus) it seems to work now.

This is my working code:
B4X:
            'Register with the VOIP service
            Sip.Initialize("SIP","U123456","xxxx.nl","xxxx")
            Dim r As Reflector
            r.Target = Sip
            Dim builder As JavaObject = r.GetField("builder")
            builder.RunMethod("setAuthUserName", Array("UA123456"))
            Sip.OutboundProxy="xx.xxx.xx.xx"
            Sip.Port=5060
            Sip.Register

It seems that changing something within the builder, you need to restart Android.
This way I solved the following errors:
SIP Failed, ErrorCode=-9
SIP Failed, ErrorCode=-3

Thanks for helping me.

BR, André
 
Last edited:
Upvote 0
Top