pjsip-android icon indicating copy to clipboard operation
pjsip-android copied to clipboard

No broadcast event receive when callee hang up call

Open TienHai opened this issue 3 years ago • 22 comments
trafficstars

Hi,

when successed make call, when callee hang up call, no broadcast event received ?

=> onCallState not called with pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED ?

Thanks!

TienHai avatar Dec 20 '21 10:12 TienHai

In my case it's called PJSIP_INV_STATE_DISCONNECTED

waheedkhan-dev avatar Dec 20 '21 11:12 waheedkhan-dev

can you share your code of call hang up?

waheedkhan-dev avatar Dec 20 '21 11:12 waheedkhan-dev

    private fun testCall(phoneNumber: String){
        try{
            SipServiceCommand.makeCall(this, mAccountId, phoneNumber, false, false, false)
        } catch (e:Exception){
            e.printStackTrace()
            Toast.makeText(this, "Account error", Toast.LENGTH_SHORT).show()
        }
    }

 private fun testHangUpCall(){
        Log.i("MainActivity", "hangUpCall => mAccountId: $mAccountId, mCallId: $mCallId")
        mAccountId?.let {  account ->
            mCallId?.let {
                SipServiceCommand.hangUpCall(this, mAccountId, it)
            }
        }
    }

    private var mReceiver: BroadcastEventReceiver = object : BroadcastEventReceiver() {
        override fun onCallState(accountID: String?, callID: Int, callStateCode: Int, callStatusCode: Int, connectTimestamp: Long) {
            super.onCallState(accountID, callID, callStateCode, callStatusCode, connectTimestamp)

            Log.i("MainActivity", "onCallState => accountID: $accountID")
            Log.i("MainActivity", "onCallState => callID: $callID")
            when(callStateCode){
                pjsip_inv_state.PJSIP_INV_STATE_CALLING-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_CALLING")
                    mCallId = callID
                }
                pjsip_inv_state.PJSIP_INV_STATE_INCOMING-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_INCOMING")
                }
                pjsip_inv_state.PJSIP_INV_STATE_EARLY-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_EARLY")
                }
                pjsip_inv_state.PJSIP_INV_STATE_CONNECTING-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_CONNECTING")
                }
                pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_CONFIRMED")
                }
                pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED-> {
                    Log.i("MainActivity", "onCallState => PJSIP_INV_STATE_DISCONNECTED")
                    mCallId = null
                }
                else -> {
                    Log.i("MainActivity", "onCallState => $callStateCode")
                }
            }
        }
    }

  • When call testHangUpCall: OK, BroadcastEventReceiver -> onCallState -> pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED receive.

  • When callee hang up call : KO not receive DISCONNECTED

Thanks

TienHai avatar Dec 21 '21 12:12 TienHai

Try this to hangup the call var prm = sipController.getCallOptionalParameter() prm.statusCode = pjsip_status_code.PJSIP_SC_DECLINE sipController.getCurrentCall().hangup(prm)

waheedkhan-dev avatar Dec 22 '21 16:12 waheedkhan-dev

Can you share the code of deinitialize sip connection? My app crash on poor internet connection

waheedkhan-dev avatar Dec 22 '21 16:12 waheedkhan-dev

Hi,

Is not my problem, when i'm hang up the call, no problem DISCONNECTED was called

Try this to hangup the call
var prm = sipController.getCallOptionalParameter()
prm.statusCode = pjsip_status_code.PJSIP_SC_DECLINE
sipController.getCurrentCall().hangup(prm)   

But, when the callee hang up call, , i'm not receive DISCONNECTED from onCallState.

Here, how I deinitialize sip connection :

   override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mReceiver.register(this)

        mAccount = SipAccountData()
        mAccount.host = sipServer
        mAccount.realm = sipServer
        mAccount.port =sipPort

        mAccount.username = userName
        mAccount.password = userPwd
        mAccountId = SipServiceCommand.setAccount(this, mAccount)
   }

    override fun onDestroy() {
        super.onDestroy()
        mReceiver.unregister(this)
        mAccountId?.let { SipServiceCommand.removeAccount(this, it) }
    }

TienHai avatar Dec 22 '21 19:12 TienHai

Sorry I think you have a problem on your side related to hangup call

waheedkhan-dev avatar Dec 23 '21 12:12 waheedkhan-dev

Can you give me your mail or something so we can communicate privately..!!

waheedkhan-dev avatar Dec 23 '21 13:12 waheedkhan-dev

Hi, any updates on this issue please?

Mohammed-Al-Hafidh avatar May 25 '22 18:05 Mohammed-Al-Hafidh

No i think pjsip has no strong community to ans pjsip queries

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Mohammed Al-Hafidh @.> Sent: Wednesday, May 25, 2022 11:57:47 PM To: VoiSmart/pjsip-android @.> Cc: Waheed khAn @.>; Comment @.> Subject: Re: [VoiSmart/pjsip-android] No broadcast event receive when callee hang up call (Issue #152)

Hi, any updates on this issue please?

— Reply to this email directly, view it on GitHubhttps://github.com/VoiSmart/pjsip-android/issues/152#issuecomment-1137726683, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANFMC2MELROK4MISEQQDBMTVLZZ2XANCNFSM5KNMTWXA. You are receiving this because you commented.Message ID: @.***>

waheedkhan-dev avatar May 25 '22 19:05 waheedkhan-dev

to try to find te root cause you should look a te sip messages exchanged with the server, e.g.: sniff all the messages and see if the BYE sent by server/remote side is sent to some other address/port.

aenonGit avatar Oct 28 '22 07:10 aenonGit

If remote asterik server is let's say custom_forwarding your call. It treats that as a second call and declines it. This was my case. I had to store the call id separately and on disconnect match it with the stored value. Try debugging or explain the issue more

ashishsecrets avatar Mar 24 '23 19:03 ashishsecrets

Sorry I think you have a problem on your side related to hangup call

Hi, I am having a similar issue with hang up call. Do you know if there is a resolution?

oleohi avatar May 15 '23 16:05 oleohi

Hi, I also have a similar problem on hang up call. My code seems fine from what I compare with the documentation and other snippets shared in examples. But still no solution. Any help is deeply appreciated.

oleohi avatar May 15 '23 16:05 oleohi

Can you give me your mail or something so we can communicate privately..!!

Hi. I'm having a similar issue. I don't mind a private conversation if you're interested. thank you.

oleohi avatar May 15 '23 16:05 oleohi

@aenonGit

if a call is less than 15 seconds long, and the other person hangs up, I receive the BYE packet with no problem.

If the call is more than 45 seconds long, and the other person hangs up, I don't receive the BYE packet at all, so the call shows as still in progress. Wireshark doesn't catch the packet either. I checked with the backend and it's definitely sending the packet, I'm just not receiving it on my end.

I'm using UDP

Any ideas?

kukadiyaAni avatar Dec 08 '23 11:12 kukadiyaAni

Issue is actually with the call id. This project is not able to track the call sometimes as the call id changes. I have tested it and fixed it too. I have the fixed project as private on github as it as clients data too. I will try to make it public by Sunday.

ashishsecrets avatar Dec 08 '23 17:12 ashishsecrets

@ashishsecrets Great thanks, it will great help for me

kukadiyaAni avatar Dec 09 '23 16:12 kukadiyaAni

@kukadiyaAni Here is the sample project as promised. Let me know if you have any difficulty https://github.com/ashishsecrets/pjsip-android-sample-proj/tree/master

ashishsecrets avatar Dec 10 '23 06:12 ashishsecrets

@ashishsecrets Thanks, I checked out your repo it's great, just one thing need to know for my case onCallState not called from PJSIP, what did you do for that?

Actually I already customized my repo for react-native so, if I get what exactly cause so, I can add that solution

Thanks again for your repo

kukadiyaAni avatar Dec 11 '23 05:12 kukadiyaAni

@kukadiyaAni I don't remember fully all the changes but if you look in my repo and open the sip service(which is the voismart pjsip main project) you will see I have modified the call ids from number to string at some places also how I'm using the call id in the main activity and tracking it please check that logic. That's all really.

ashishsecrets avatar Dec 11 '23 06:12 ashishsecrets

@ashishsecrets Thanks for your support, I think our issue is different, the local broadcast working fine, in my case below method not called from PJSIP when call ends after 1 minute

public void onCallState(OnCallStateParam prm) {
    Log.e( "onCallState: ", getInfo().getState());
    if (getClass() == Call.class) pjsua2JNI.Call_onCallState(swigCPtr, this, OnCallStateParam.getCPtr(prm), prm); else pjsua2JNI.Call_onCallStateSwigExplicitCall(swigCPtr, this, OnCallStateParam.getCPtr(prm), prm);
  }

kukadiyaAni avatar Dec 11 '23 08:12 kukadiyaAni