0

I am using Android SIP API to create my sip client and FREE PBX for sip server. But I am facing this issue, while calling to some extension, if this user is not registered to server, it gives me the error response in 8 seconds. Here is my code.

SipAudioCall.Listener listener = new SipAudioCall.Listener() {
            // Much of the client's interaction with the SIP Stack will
            // happen via listeners. Even making an outgoing call, don't
            // forget to set up a listener to set things up once the call is
            // established.
            @Override
            public void onCallEstablished(SipAudioCall call) {
                call.startAudio();
                call.setSpeakerMode(true);
                if (call.isMuted())
                    call.toggleMute();
                updateStatus("call established.");
            }

            @Override
            public void onCallEnded(SipAudioCall call) {
                updateStatus("call ended.");
            }

            @Override
            public void onError(SipAudioCall call, int errorCode,
                    String errorMessage) {
                delay = System.currentTimeMillis() - delay;
                delay = delay / 1000;
                Log.v("", "call failed: time taken in decision is " + delay
                        + " seconds.");
                endCall(call);
                makeGsmCall(numberString);
                super.onError(call, errorCode, errorMessage);
            }
        };
        delay=System.currentTimeMillies();
        SipState.sipAudioCall = SipState.sipManager.makeAudioCall(SipState.localSipProfile.getUriString(), sipAddress,
                listener, 0);

In this code, the onError(), method is called after 8 seconds. Can we minimize that? Or if there is some other method we could achieve that?

Also I have seen other applications like sipdroid and linephone, they seem to take no time to tell that specified username is unavailable.

Please help me. Thanks.

Anuj Garg
  • 959
  • 10
  • 12

1 Answers1

1

When your SIP registers it sends acknowledgement. If it is fine. the response you will get will be "Ready" otherwise it will give you an errorCode which can be seen at this page

https://stuff.mit.edu/afs/sipb/project/android/OldFiles/docs/reference/android/net/sip/SipErrorCode.html

By refering to this you can see what error you are getting. Also there is a string for Error Message. you can save that in string and then show on UI.

Hope this helps

safiulm
  • 85
  • 1
  • 1
  • 5