Asterisk AGI Python Script completed, returning 0 -


i used online tutorial run python script in asterisk using agi. returns,

agi script easy.py completed, returning 0 

so enabled debug mode , got output.

agi debugging enabled

== using sip rtp tos bits 184   == using sip rtp cos mark 5     -- executing [0112617769@from-trunk:1] answer("sip/obitrunk1-0000000b", "")  in new stack   -- executing [0112617769@from-trunk:2] agi("sip/obitrunk1-0000000b", "easy.py") in new stack     -- launched agi script /var/lib/asterisk/agi-bin/easy.py <sip/obitrunk1-0000000b>agi tx >> agi_request: easy.py <sip/obitrunk1-0000000b>agi tx >> agi_channel: sip/obitrunk1-0000000b <sip/obitrunk1-0000000b>agi tx >> agi_language: en <sip/obitrunk1-0000000b>agi tx >> agi_type: sip <sip/obitrunk1-0000000b>agi tx >> agi_uniqueid: 1503228907.11 <sip/obitrunk1-0000000b>agi tx >> agi_version: 13.15.0 <sip/obitrunk1-0000000b>agi tx >> agi_callerid: 0713029474 <sip/obitrunk1-0000000b>agi tx >> agi_calleridname: unknown <sip/obitrunk1-0000000b>agi tx >> agi_callingpres: 0  <sip/obitrunk1-0000000b>agi tx >> agi_callingani2: 0 <sip/obitrunk1-0000000b>agi tx >> agi_callington: 0 <sip/obitrunk1-0000000b>agi tx >> agi_callingtns: 0 <sip/obitrunk1-0000000b>agi tx >> agi_dnid: 0112617769 <sip/obitrunk1-0000000b>agi tx >> agi_rdnis: unknown <sip/obitrunk1-0000000b>agi tx >> agi_context: from-trunk <sip/obitrunk1-0000000b>agi tx >> agi_extension: 0112617769 <sip/obitrunk1-0000000b>agi tx >> agi_priority: 2 <sip/obitrunk1-0000000b>agi tx >> agi_enhanced: 0.0 <sip/obitrunk1-0000000b>agi tx >> agi_accountcode:  <sip/obitrunk1-0000000b>agi tx >> agi_threadid: 1956721696 <sip/obitrunk1-0000000b>agi tx >>     -- <sip/obitrunk1-0000000b>agi script easy.py completed, returning 0     -- auto fallthrough, channel 'sip/obitrunk1-0000000b' status 'unknown'    -- executing [h@from-trunk:1] answer("sip/obitrunk1-0000000b", "") in new stack   == spawn extension (from-trunk, h, 1) exited non-zero on 'sip/obitrunk1-0000000b'   == using sip rtp tos bits 184  == using sip rtp cos mark 5     -- executing [0112617769@from-trunk:1] answer("sip/obitrunk1-0000000c", "")  in new stack    -- executing [0112617769@from-trunk:2] agi("sip/obitrunk1-0000000c", "easy.py") in new stack     -- launched agi script /var/lib/asterisk/agi-bin/easy.py <sip/obitrunk1-0000000c>agi tx >> agi_request: easy.py <sip/obitrunk1-0000000c>agi tx >> agi_channel: sip/obitrunk1-0000000c <sip/obitrunk1-0000000c>agi tx >> agi_language: en <sip/obitrunk1-0000000c>agi tx >> agi_type: sip <sip/obitrunk1-0000000c>agi tx >> agi_uniqueid: 1503228913.12 <sip/obitrunk1-0000000c>agi tx >> agi_version: 13.15.0 <sip/obitrunk1-0000000c>agi tx >> agi_callerid: obitrunk1 <sip/obitrunk1-0000000c>agi tx >> agi_calleridname: unknown <sip/obitrunk1-0000000c>agi tx >> agi_callingpres: 0 <sip/obitrunk1-0000000c>agi tx >> agi_callingani2: 0 <sip/obitrunk1-0000000c>agi tx >> agi_callington: 0 <sip/obitrunk1-0000000c>agi tx >> agi_callingtns: 0 <sip/obitrunk1-0000000c>agi tx >> agi_dnid: 0112617769 <sip/obitrunk1-0000000c>agi tx >> agi_rdnis: unknown <sip/obitrunk1-0000000c>agi tx >> agi_context: from-trunk <sip/obitrunk1-0000000c>agi tx >> agi_extension: 0112617769 <sip/obitrunk1-0000000c>agi tx >> agi_priority: 2 <sip/obitrunk1-0000000c>agi tx >> agi_enhanced: 0.0 <sip/obitrunk1-0000000c>agi tx >> agi_accountcode:  <sip/obitrunk1-0000000c>agi tx >> agi_threadid: 1980019744 <sip/obitrunk1-0000000c>agi tx >>      -- <sip/obitrunk1-0000000c>agi script easy.py completed, returning 0   -- auto fallthrough, channel 'sip/obitrunk1-0000000c' status 'unknown'      -- executing [h@from-trunk:1] answer("sip/obitrunk1-0000000c", "") in new stack == spawn extension (from-trunk, h, 1) exited non-zero on 'sip/obitrunk1-0000000c'   == using sip rtp tos bits 184 

above code got when receive call. there 3 problems want solve.

problems

1) shows

agi script easy.py completed, returning 0 

and don't know why. online forum suggested, changed easy.py location /var/test/easy.py didn't work. wanna solve since not give expect.

this easy.py code.

#!/usr/bin/env python import sys asterisk.agi import *  agi = agi() agi.verbose("python agi started") callerid = agi.env['agi_callerid'] agi.verbose("call %s" % callerid) while true:   agi.stream_file('vm-extension')   result = agi.wait_for_digit(-1)   agi.verbose("got digit %s" % result)   if result.isdigit():     agi.say_number(result)   else:    agi.verbose("bye!")    agi.hangup()    sys.exit() 

2) when phone rings, can see easy.py has executed 2 times. (this shows 2 times when keeps ringing executes in loop). couldn't find solution that. second loop, starts show callerid obitrunk1.

3) when code runs, landline phone stops ringing when remove code extensions.conf file , place standard extensions.conf codes, landline rings does.

note : know wrong. since adding extensions extensions_custom.conf didn't work, modified extensions.conf file. below how extensions.conf file looks when agi works.

extensions.conf

from trunk: [from-trunk] exten => _x.,1,answer() exten => _x.,n,agi(/var/test/easy.py) 

hope can me. tried find solutions them in several web sites , books, had no luck. thank you.

that likly mean have error(syntax or other) in script.

please note, debug oftoppic on so.

for debug script, first stop asterisk

asterisk -rx "core stop now" 

after start in console

asterisk -vvvvgc 

and call


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -