-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Labels
Description
I was trying the example:-
from switchio.apps.routers import Router
router = Router(guards={
'Call-Direction': 'inbound',
})
@router.route('(.*)')
async def welcome(sess, match, router):
"""Say hello to inbound calls.
"""
await sess.answer() # resumes once call has been fully answered
sess.log.info("Answered call to {}".format(match.groups(0)))
sess.playback('media.mp3') # non-blocking
sess.log.info("Playing welcome message")
await sess.recv("PLAYBACK_STOP")
await sess.hangup() # resumes once call has been fully hungup
After the media playback was done, the call just stay there and didn't hangup. After hanging up from the caller, I got this:-
07:05:31 ~/swio$ switchio serve 127.0.0.1 --app ./dialplan.py:router --password=cluecon
Dec 02 07:05:34 (MainThread) [WARNING] root storage.py:23 : No module named 'pandas'
Dec 02 07:05:34 (MainThread) [INFO] switchio.EventLoop@127.0.0.1 loop.py:182 : Connected event loop 'c13c11e8-d6e3-11e7-adb4-06f257f4adeb' to '127.0.0.1'
Dec 02 07:05:34 (MainThread) [INFO] switchio.Client@127.0.0.1 api.py:145 : Loading 'Router' app with group id 'default' for event_loop '<switchio.loop.EventLoop object at 0x7fe01c9f69b0 [connected]>'
XXXXX CHANNEL_CREATE
XXXXX CHANNEL_PARK
XXXXX CHANNEL_ANSWER
Dec 02 07:05:43 (switchio_event_loop[127.0.0.1]) [INFO] switchio.str@unknown-host dialplan.py:12 : Answered call to ('60180044545',)
Dec 02 07:05:43 (switchio_event_loop[127.0.0.1]) [INFO] switchio.str@unknown-host dialplan.py:15 : Playing welcome message
XXXXX CHANNEL_HANGUP
Dec 02 07:06:46 (switchio_event_loop[127.0.0.1]) [WARNING] switchio.EventLoop@127.0.0.1 loop.py:336 : Cancelling PLAYBACK_STOP awaited <Future pending cb=[Session.unreg_tasks(), <TaskWakeupMethWrapper object at 0x7fe01c1ea708>()]>
Stack for <Task pending coro=<Router.on_park() running at /home/kamal/miniconda3/lib/python3.6/site-packages/switchio/apps/routers.py:151> wait_for=<Future pending cb=[Session.unreg_tasks(), <TaskWakeupMethWrapper object at 0x7fe01c1ea708>()]> cb=[handle_result(log=<Logger switc....0.0.1 (INFO)>, model=<switchio.mod...-1559c2c9995a>)() at /home/kamal/miniconda3/lib/python3.6/site-packages/switchio/loop.py:45]> (most recent call last):
File "/home/kamal/miniconda3/lib/python3.6/site-packages/switchio/apps/routers.py", line 151, in on_park
await func()
Dec 02 07:06:46 (switchio_event_loop[127.0.0.1]) [ERROR] switchio.Router@['127.0.0.1'] routers.py:161 : Failed to exec <function welcome at 0x7fe01c1cd378> on match '601800818638' for session a41f4956-f556-4b41-9f03-1559c2c9995a
Traceback (most recent call last):
File "/home/kamal/miniconda3/lib/python3.6/site-packages/switchio/apps/routers.py", line 151, in on_park
await func()
File "./dialplan.py", line 16, in welcome
await sess.recv("PLAYBACK_STOP")
concurrent.futures._base.CancelledError
^CDec 02 07:07:02 (MainThread) [INFO] switchio.EventLoop@127.0.0.1 loop.py:417 : Disconnecting event loop 'c13c11e8-d6e3-11e7-adb4-06f257f4adeb' from '127.0.0.1'
XXXXX SERVER_DISCONNECTED
Dec 02 07:07:02 (switchio_event_loop[127.0.0.1]) [WARNING] switchio utils.py:202 : Event 'SERVER_DISCONNECTED' has no timestamp!?
Dec 02 07:07:02 (switchio_event_loop[127.0.0.1]) [WARNING] switchio.EventListener@127.0.0.1 handlers.py:157 : Received DISCONNECT from server '127.0.0.1'
I print the evname
in loop.py:_listen_forever()
and we can see, no PLAYBACK_STOP coming. I was connected through telnet in the other console and I can see PLAYBACK_STOP coming to that connection so the event was fired by freeswitch.