Android Question Question Regarding SIP , Problem getting error code = -9

abdulla

Member
Licensed User
i have question regarding implementing sip libraray , i have used it in test client as a service module , i have coded the the sip code from example was published previously in the forum , the code is as follows this is my Service Module :

Dim Sip As Sip
Dim CurrentCall As SipAudioCall
End Sub
Sub Service_Create
End Sub

Sub Service_Start (StartingIntent As Intent)
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", "xxxx@xxxx.onsip.com","xxxx")
' Sip.Initialize("SIP","xxxx","xxxx.onsip.com","xxxx")
Sip.register
If Sip.IsInitialized = True Then
ToastMessageShow("SIP Intialized.", True)
End If

End If
End If
End Sub

Sub Service_Destroy

End Sub
Sub SIP_Registering
Log("Registering")
ToastMessageShow("Registering", True)
End Sub
Sub SIP_RegistrationFailed (ErrorCode As Int, ErrorMessage As String)
Log("Failed, ErrorCode=" & ErrorCode & ", Message=" & ErrorMessage)
ToastMessageShow("Registration failed.", True)
End Sub

Sub SIP_RegistrationDone (ExpiryTime As Long)
Log("RegistrationDone, ExpiryTime=" & ExpiryTime)
ToastMessageShow("SIP registered sucessfully", True)
' Main.Connect_peer.Enabled = True
End Sub

Sub SIP_CallEstablished
'Check that we are not already in a call.
'Seems like this event can be raised by the SIP service multiple times.
If CurrentCall.IsInCall Then Return

CurrentCall.StartAudio 'Start the audio
CurrentCall.SpeakerMode = True
ToastMessageShow("Call established", True)
End Sub
'Incoming call
Sub SIP_CallRinging (IncomingCall As SipAudioCall)
Log("CallRinging")
ToastMessageShow("Ringing from: " & IncomingCall.PeerUri, True)
CurrentCall = IncomingCall
End Sub




but i keep getting this error in the log :

Failed, ErrorCode=-9, Message=0

when ever the app is trying to register , i have made some efforts to debug it o see weather it actually sent the request to the server , i have changed the host uri and made it wrong as "xxxx.onsip.comxxx" just to see weather it wold give me network error or not but still get the same error as errorcode= -9 .

i have also installed "Csipsimple" client fom Google play market , and then used the same uri "xxxx.onsip.com" and username and password , and csipsimple client connected successfully , which meant that the registration process should be successful also with the b4a code , but i think as of my debugging that my code above does not even connect to the sip server the problem is in the Register process, i don't get "registering" at all, i get "SIP Intialized." but after that i always get error code = -9 , i am using the same phone "samsung galaxy 3 mini"

I also have included this line in the manifest file :
AddPermission (android.permission.USE_SIP)


my question Why do i keep getting
Failed, ErrorCode=-9, Message=0

always


I will appreciate any help

Thanks
 

abdulla

Member
Licensed User
Thank You Erel for your quick reply, Could you suggest any solution to fix this problem ,every time i run the example app as the code i showed . on my phone , i get this problem , so i would appreciate it if you have any solutions i could implement it . and thanks again for your quick reply
 

abdulla

Member
Licensed User
Please use [code]code here...[/code] tags when posting code.

-9 means: The client is in a transaction and cannot initiate a new one.

Note that other apps might implement the SIP protocol themselves so they can work even if the native SIP feature doesn't.
for update on this problem i found a solution to the problem , i previously have used also "Officesip" server as i installed it , I just added the following code

B4X:
Sip.Port =  xxxx    <------   the port number i am using  for the server on the server side 

.
just before before Sip.Initialize2 ,

Sip.Port = xxxx
Sip.Initialize2( )

and now i am getting "SIP registered successful"

as connecting to "officesip" server .

So thanks again Erel , I do appreciate your quick reply.
 

abdulla

Member
Licensed User
for update on this problem i found a solution to the problem , i previously have used also "Officesip" server as i installed it , I just added the following code

B4X:
Sip.Port =  xxxx    <------   the port number i am using  for the server on the server side

.
just before before Sip.Initialize2 ,

Sip.Port = xxxx
Sip.Initialize2( )

and now i am getting "SIP registered successful"

as connecting to "officesip" server .

So thanks again Erel , I do appreciate your quick reply.

UPDATE- For Correction the code above should be this way :

Sip.Initialize2( ) <--- first initialize
Sip.Port = xxxx <---- then set the port
 

xeriko

Member
Licensed User
dear abdula,

may you say how to do this with officesip. I installed it and i can connect via zoiper but with native sip i can't

may you share your experience?
 

deantangNYP

Active Member
Licensed User
I am getting the same "error code -9" on Linphone.
How would i know the Port number?

B4X:
    'SIP
    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
            Sip.Initialize2("SIP", "sip:abcdef@sip.linphone.org", "password")
            Sip.Register
        End If
    End If
 
Top