Android Question VoIP/SIP - Error when calling: Network unavailable?

Kjell

Member
Licensed User
Longtime User
This is my first post, so hi all :)
The reason I haven't had any posts yet, is because when I stumbled upon a problem, I always found the solution in the forums. I got to say, this is great!!

But now, I am trying to do a VoIP/SIP app and started out with Erels SIP example.
I moved the SIP code to a service, and made successful calls from my computer to the phone (with sound), but when I try to call from my phone to my computer, I get an error that says it failed to create the SIP session, and asks me if I am connected to the internet.

When I use the SIP example I can receive and make calls, and I copied the SIP addresses so they should be correct.

The error message:
B4X:
java.lang.RuntimeException: java.lang.RuntimeException: android.net.sip.SipException: Failed to create SipSession; network unavailable?



I use this to start calling (Never mind that there is no values from the list passed on, that is for later, just testing so far)

In the Activity to start a call:
B4X:
Sub lstContacts_ItemClick (Position As Int, Value As Object)
    CallSub(calls, "sbMakeCall")
End Sub



In the service named "calls":
B4X:
Sub sbMakeCall
    'Makes a call.
    'The audio will start after the CallEstablished event is raised.
    CurrentCall = Sip.MakeCall("sip:***@iptel.org", 30) 'I get the error here
End Sub

Its really not much different then the example.



B4X:
Installing file.
GC_CONCURRENT freed 433K, 17% free 10583K/12612K, paused 19ms+5ms, total 82ms
GC_CONCURRENT freed 491K, 17% free 10582K/12612K, paused 4ms+10ms, total 173ms
WAIT_FOR_CONCURRENT_GC blocked 64ms
PackageAdded: package:com.nordiccreation.voip
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (calls) Create **
** Service (calls) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (contacts) Create, isFirst = true **
** Activity (contacts) Resume **
android.net.sip.SipException: Failed to create SipSession; network unavailable?
    at android.net.sip.SipManager.createSipSession(SipManager.java:554)
    at android.net.sip.SipManager.makeAudioCall(SipManager.java:327)
    at android.net.sip.SipManager.makeAudioCall(SipManager.java:358)
    at anywheresoftware.b4a.objects.SIP.MakeCall(SIP.java:199)
    at com.nordiccreation.voip.calls._sbmakecall(calls.java:220)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:173)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:858)
    at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:807)
    at com.nordiccreation.voip.contacts._lstcontacts_itemclick(contacts.java:404)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:173)
    at anywheresoftware.b4a.BA$2.run(BA.java:283)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
    at dalvik.system.NativeStart.main(Native Method)
 
Last edited:

lemonisdead

Well-Known Member
Licensed User
Longtime User
I am not an expert but couldn't it be the Windows firewall blocking the Sip traffic (as you were able to pass a call from the PC to the phone and not the reverse) ?
 
Upvote 0

Kjell

Member
Licensed User
Longtime User
I am not an expert but couldn't it be the Windows firewall blocking the Sip traffic (as you were able to pass a call from the PC to the phone and not the reverse) ?

Nice thought, :)
but when I use the SIP example downloaded from B4A and calls from my phonephone to the computer it works so I don't think that's it. :(
 
Upvote 0

Kjell

Member
Licensed User
Longtime User
Are you waiting for the RegistrationDone event?
To be honest, I am not sure.
I was able to call from my computer to the phone, so I guess the RegistrationDone event is done by then?

I copied all the example code to a new activity, worked like a charm.
I then added a lot of logs trying to pinpoint the problem, ran the app tried to call my computer and waited for the error.... then it rang on my computer, and I am scratching my head.
Well, the problem is gone o_O

I also did delete
B4X:
If CurrentCall.IsInitialized Then
       CurrentCall.EndCall
End If
That was somehow ended up doubled in
B4X:
Sub SIP_CallEnded
, but I don't see how that should affect me calling from my phone.
I don't know, maybe it just got scared of all the extra logs and behaved? :p
 
Last edited:
Upvote 0
Top