Asterisk AGI Python Script to Dialplan does not work -




i'm stuck project have check database of sip extension incoming caller id , dial sip extension. below receive when run script on asterisk cli.

-- registered sip '9125' @ 192.168.1.102:50142     > saved useragent "zoiper rv2.8.40" peer 9125 [2017-08-22 13:53:33] notice[5095]: chan_sip.c:24558 handle_response_peerpoke: peer '9125' reachable. (17ms / 2000ms) == using sip rtp tos bits 184 == using sip rtp cos mark 5     -- executing [0112617769@from-trunk:1] answer("sip/obitrunk1-0000000d", "") in new stack     > 0x1ca50d0 -- probation passed - setting rtp source address 192.168.1.98:16834     -- executing [0112617769@from-trunk:2] agi("sip/obitrunk1-0000000d", "test.py") in new stack     -- launched agi script /var/lib/asterisk/agi-bin/test.py args: ['/var/lib/asterisk/agi-bin/test.py'] env line: agi_request: test.py env line: agi_channel: sip/obitrunk1-0000000d env line: agi_language: en env line: agi_type: sip env line: agi_uniqueid: 1503406442.13 env line: agi_version: 13.15.0 env line: agi_callerid: 0713929474 env line: agi_calleridname: unknown env line: agi_callingpres: 0 env line: agi_callingani2: 0 env line: agi_callington: 0 env line: agi_callingtns: 0 env line: agi_dnid: 0112617799 env line: agi_rdnis: unknown env line: agi_context: from-trunk env line: agi_extension: 0112617799 env line: agi_priority: 2 env line: agi_enhanced: 0.0 env line: agi_accountcode: env line: agi_threadid: 1977119776 env line:  class agi: self.env = {'agi_accountcode': '', 'agi_callerid': '0713029474', 'agi_calleridname': 'unknown', 'agi_callingani2': '0', 'agi_callingpres': '0', 'agi_callingtns': '0', 'agi_callington': '0', 'agi_channel': 'sip/obitrunk1-0000000d', 'agi_context': 'from-trunk', 'agi_dnid': '0112617799', 'agi_enhanced': '0.0', 'agi_extension': '0112617799', 'agi_language': 'en', 'agi_priority': '2', 'agi_rdnis': 'unknown', 'agi_request': 'test.py', 'agi_threadid': '1977119776', 'agi_type': 'sip', 'agi_uniqueid': '1503406442.13', 'agi_version': '13.15.0'}     command: verbose "python agi started" 1     result_line: 200 result=1 test.py: python agi started     result_dict: {'result': ('1', '')}     command: verbose "call 0713929474" 1     result_line: 200 result=1 test.py: call 0713029474     result_dict: {'result': ('1', '')}     command: verbose "mysql started" 1     result_line: 200 result=1 test.py: mysql started     result_dict: {'result': ('1', '')}     command: verbose "mysql executed" 1     result_line: 200 result=1 test.py: mysql executed     result_dict: {'result': ('1', '')}     command: verbose "mysql fetched" 1     result_line: 200 result=1 test.py: mysql fetched     result_dict: {'result': ('1', '')}     command: verbose "database sip number : 9125 " 1     result_line: 200 result=1 test.py: database sip number : 9125      result_dict: {'result': ('1', '')}     command: set variable "sipexten" "9125"     result_line: 200 result=1     result_dict: {'result': ('1', '')}     command: verbose "sip number set" 1 test.py: sip number set     result_line: 200 result=1     result_dict: {'result': ('1', '')}     -- <sip/obitrunk1-0000000d>agi script test.py completed, returning 0     -- auto fallthrough, channel 'sip/obitrunk1-0000000d' status 'unknown' 

this test.py script last part.

#!/usr/bin/python  import mysqldb import sys asterisk.agi import *  agi = agi() agi.verbose("python agi started") callerid = agi.env['agi_callerid'] agi.verbose("call %s" % callerid) . . #some additional code running smoothly. . agi.verbose("database sip number : %s " % sipstr)  agi.set_variable('sipexten',int(sipstr)) agi.verbose("sip number set")  # disconnect server db.close() 

this problem. when call number cli output shows, gives me correct sip extension database. assign value dialplan variable below dialplan code part.

;******************************************************************************* ; dialplan open public, using inbound dids , similar                  * ;******************************************************************************* ; ;------------------------------------------------------------------------------- ; from-trunk: ; ; context aliax of from-pstn ; [from-trunk] exten => _x.,1,answer exten => _x.,n,agi(test.py) exten => _x.,n,dial(sip/${sipexten})   [from-sip-external] exten => _x.,1,answer exten => _x.,n,agi(test.py) exten => _x.,n,dial(sip/${sipexten}) ;------------------------------------------------------------------------------- 

as cli output shows this,

test.py: database sip number : 9125      result_dict: {'result': ('1', '')}     command: set variable "sipexten" "9125"     result_line: 200 result=1     result_dict: {'result': ('1', '')}     command: verbose "sip number set" 1 

it's obvious value has been added dialplan variable (as think?). call not transfer sip extension.

note : used asterisk -vvvvgc cl interface. sip registered , available in time. call comes from-trunk context.

i couldn't find internet after hours of search. can me?





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -