0

Introduction

We are using Plivo PHP Server-side SDK (legacy version) to manage inbound calls. Recently I had to implement call blocking. Idea is simple - If inbound call in our system does not match certain rules, we hang up. For that hangup_call function from RestAPI is used.

Piece of Code

When our system receives request with Event: StartApp from Plivo, call controller calls StartCall class function handle. This function contains all logic for starting call(checking rules, saving call in data base, start recording, etc):

public function handle($data) {
    // Finding caller from DB by callerNumber ...
    // Finding campaign from DB by targetNumber ...
    // Checking if caller already called in certain time interval (isDuplicate) ...

    // Starting call - call MUST be saved in DB !
    $call = Call::start($data["CallUUID"], $campaign, $caller, $isDuplicate);
    $call->save();

    try {
        // Checking call rules, throwing exceptions and changing call status accordingly
        $call->guardCall();
    } catch (CountryNotAllowedException $e) {
        // Hanging up if caller country not allowed
        return $this->callsApi->hangUp($call);
    } 
    // If everything went good waiting(Plivo addWait) for our systems waiting call service to find call consumer and execute transfer...
}

Note: hangUp is function that contains hangup_call alongside with some logging.

Testing

At the moment, for call testing we use skype with purchased US numbers since we are located in Europe.

For testing purposes, every call in this test does not pass rules - is blocked.

When testing this code everything seemed to work, but there is one issue - skype(caller) keeps connecting although Plivo ended call. In result, after our system receives Hangup from Plivo a new call starts. And this is repeating in cycle until I manually end call in skype as caller.

Using addSpeak or addWait instead of hangup_call works - speak or wait is executed and after that call ends.

I also tried use addHangup with parameter reason: "rejected", but there was no difference.

Question

Why after hangup_call is executed skype keeps connecting? (Call is not ended in caller side)

Could it be skype's peculiarity?

Maybe it is because we use legacy version SDK? Is there a big difference between latest and legacy Server-side SDK?

Andrej
  • 1
  • I don't think that's the recommended way to use exceptions. Aside from that, is there a distinction between hanging up and refusing a call? I'm wondering if Skype has some sort of auto redial because it isn't registering that the call was refused. – Anthony May 08 '18 at 16:37
  • What happens on the Skype caller's end when the call is rejected? Does it appear to disconnect and reconnect, or just continue ringing? – Anthony May 08 '18 at 16:44
  • @Anthony In both cases - hangup and rejecting (hangup with reason "rejected") Skype keeps ringing. – Andrej May 09 '18 at 07:24
  • Are you by change using the sequential dial feature? Also are you passing the CallUUID to the hang_up function? $plivo->hangup_call(CallUUID); The relevant code and response would help figure it out. – mathius1 Sep 20 '18 at 21:46

0 Answers0