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

Discussion in 'Android Questions' started by abdulla, Feb 2, 2015.

  1. abdulla

    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
     
  2. Erel

    Erel Administrator Staff 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.
     
  3. abdulla

    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Tried it on a different device or with a different SIP provider. I tested it in the past with: http://www.iptel.org/
     
  5. abdulla

    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

    Code:
    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.
     
  6. abdulla

    abdulla Member Licensed User


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

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

    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?
     
  8. deantangNYP

    deantangNYP Active Member Licensed User

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

    Code:
    '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
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Which port number?
     
  10. deantangNYP

    deantangNYP Active Member Licensed User

    Sip.Initialize2( ) <--- first initialize
    Sip.Port = ???? <---- then set the port
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    This should be provided by the SIP service. 5060 is the standard port.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice