Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need B Leg Hangup Callback #18

Closed
mattwilliamson opened this issue Jul 11, 2011 · 19 comments
Closed

Need B Leg Hangup Callback #18

mattwilliamson opened this issue Jul 11, 2011 · 19 comments

Comments

@mattwilliamson
Copy link
Contributor

Something like <Dial blegHangupUrl="..."> so we can be notified when the dial verb terminates for rating and such.

@mike-plivo
Copy link
Member

ok added feature in dev branch :

If you set both attributes, you are tracking B legs hangup in Dial element .

In the http request you will find parameters below :
DialALegUUID
DialBLegUUID
DialBLegHangupCause

So now you can test it (sorry not tested again, I'm reinstalling my test server) :

cd /path/to/plivo/install
cd src/plivo
git pull
git checkout -b dev origin/dev

Now you are in dev branch

Restart plivo to test =)

To come back to stable version :
git checkout master

@mattwilliamson
Copy link
Contributor Author

Unfortunately didn't work. It looks like the answered event sent the b leg params instead or something, because I am expecting a To param, but I see things like called_no instead:

2011-07-12 17:10:19,963 outbound_server[32805]: INFO: (2) Requested to http://127.0.0.1:8000/_plivo/incoming/answered/ with {'direction': 'inbound', 'called_no': 'plivo', 'from_no': '1000', 'sched_hangup_id': '', 'call_uuid': '93f891d7-21ab-4602-a071-8c24ff375514', 'aleg_request_uuid': '', 'aleg_uuid': ''}

@mattwilliamson
Copy link
Contributor Author

That is upon answering the inbound call. I never made it to ending the call.

@mattwilliamson
Copy link
Contributor Author

Maybe the dev version is quite out of date?

@mike-plivo
Copy link
Member

  • dev is up to date =)
  • maybe I didn't understand your request :
    in my mind, it was :
  1. "A leg" Inbound call is starting a restxml scenario (by fetching answer url)

  2. In this restxml, you have a Dial Element to dial a "B Leg" and bridge it with "A Leg" (the incoming call) :
    <Dial BLegHangupAction="MyURL" BLegHangupMethod="POST" ... />

  3. When "B Leg" channel hangs up, "MYURL" must be fetched (else there is a bug)

@mattwilliamson
Copy link
Contributor Author

That's the correct description of the feature. It seems I was checking out an old dev branch. I got the correct one running but got the following error:

2011-07-13 13:41:19,001 outboundserver[38482]: ERROR: (6) 'Dial' object has no attribute 'get_channel_unique_id'
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6) Traceback (most recent call last):
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)   File "/Library/Python/2.6/site-packages/plivo-0.1.0-py2.6.egg/plivo/rest/freeswitch/outboundsocket.py", line 386, in _run
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)     self.process_call()
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)   File "/Library/Python/2.6/site-packages/plivo-0.1.0-py2.6.egg/plivo/rest/freeswitch/outboundsocket.py", line 414, in process_call
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)     self.execute_xml()
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)   File "/Library/Python/2.6/site-packages/plivo-0.1.0-py2.6.egg/plivo/rest/freeswitch/outboundsocket.py", line 549, in execute_xml
2011-07-13 13:41:19,002 outboundserver[38482]: ERROR: (6)     element_instance.run(self)
2011-07-13 13:41:19,003 outboundserver[38482]: ERROR: (6)   File "/Library/Python/2.6/site-packages/plivo-0.1.0-py2.6.egg/plivo/rest/freeswitch/elements.py", line 128, in run
2011-07-13 13:41:19,003 outboundserver[38482]: ERROR: (6)     result = execute(outbound_socket)
2011-07-13 13:41:19,003 outboundserver[38482]: ERROR: (6)   File "/Library/Python/2.6/site-packages/plivo-0.1.0-py2.6.egg/plivo/rest/freeswitch/elements.py", line 565, in execute
2011-07-13 13:41:19,003 outboundserver[38482]: ERROR: (6)     % (self.bleg_hangup_url, self.bleg_hangup_method, self.get_channel_unique_id())
2011-07-13 13:41:19,003 outboundserver[38482]: ERROR: (6) AttributeError: 'Dial' object has no attribute 'get_channel_unique_id'

@mattwilliamson
Copy link
Contributor Author

Also, I think the names of the attributes should be camel-case to match the rest of the API (bLegHangupAction & bLegHangupMethod)

@mike-plivo
Copy link
Member

ok fixed error and changed to camel-case style in last dev commit =)

@mike-plivo
Copy link
Member

With Venky we were thinking about something more simple :

when doing Dial with "action" and "method", why not just adding B leg uuid in the parameters posted into http request ?

@mattwilliamson
Copy link
Contributor Author

because action does a redirect, but I want the XML to continue executing

@mattwilliamson
Copy link
Contributor Author

New Exception:

Traceback (most recent call last):
  File "core.pyx", line 337, in gevent.core.__simple_handler (gevent/core.c:4494)
TypeError: send_to_url() takes at most 4 arguments (5 given)
Failed to execute callback for active_event fd=-1 flags=INIT
  cb  = <built-in method switch of greenlet.greenlet object at 0x1035b2390>
  arg = ( ( <plivo.rest.freeswitch.inboundsocket.RESTInboundSocket object at 0x1035afb50>,
            u'http://127.0.0.1:8000/_plivo/b-leg/hung_up',
            { 'DialALegUUID': u'f3fa8ce9-021b-4d36-9618-053338130756',
              'DialBLegHangupCause': u'UNALLOCATED_NUMBER',
              'DialBLegUUID': u'fa06b595-0552-4122-99a6-922f9ab04c90'},
            u'POST'),
          { })

@mike-plivo
Copy link
Member

fixed

I was thinking something again :
we can use "action" and "method" and add B leg uuid in the parameters posted into http request
and add one extra attribute to Dial element : "redirect" :
By default redirect flag will be set to "true".
When it will be set to "false", the call won't be redirected to the http response but the http request will be fired.

<Dial action="MYURL" method="POST" redirect="false"> ... </Dial>

In the http request you will get same params as for B leg callback :

  • DialBLegUUID
  • DialHangupCause
  • DialALegUUID

@mattwilliamson
Copy link
Contributor Author

That solution sounds good to me.

On Jul 18, 2011, at 3:36, tamielreply@reply.github.com wrote:

fixed

I was thinking something again :
we can use "action" and "method" and add B leg uuid in the parameters posted into http request
and add one extra attribute to Dial element : "redirect" :
By default redirect flag will be set to "true".
When it will be set to "false", the call won't be redirected to the http response but the http request will be fired.

...

In the http request you will get same params as for B leg callback :

  • DialBLegUUID
  • DialHangupCause
  • DialALegUUID

Reply to this email directly or view it on GitHub:
https://github.com/plivo/plivo/issues/18#issuecomment-1593365

@mike-plivo
Copy link
Member

ok perfect I will do that today and will update helpers :)

@mike-plivo
Copy link
Member

Hi matt, try the last master branch revision, all things have been merged now.

So you can use now :

<Dial action="MYURL" method="POST" redirect="false"> ... </Dial>

@mattwilliamson
Copy link
Contributor Author

This works but there is no DialBLegUUID posted.

@mike-plivo
Copy link
Member

ok I'm going to fix that today

@mike-plivo
Copy link
Member

ok fixed in last commit in master branch =)

@mattwilliamson
Copy link
Contributor Author

It's all working! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants