From: Vladimir <v....@gm...> - 2012-11-24 13:16:26
|
Thanks, the server works. But script doesn't work. I tested in telnet ## test_agi.py #!/home/tester/venv/aster/bin/python # -*- coding: utf-8 -*- import asterisk.agi VERBOSE_LEVEL = 1 if __name__ == '__main__': agi = asterisk.agi.AGI() agi.verbose(u'Test message from FastAGI', VERBOSE_LEVEL) agi.hangup() ###### % telnet 127.0.0.1 26000 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. ARGS: ['/home/tester/venv/aster/opt/pyst_manager/myagi.py'] agi_network: yes agi_request: agi://127.0.0.1:26000 agi_channel: SIP/IPphone-test-00000312 agi_language: ru agi_type: SIP agi_uniqueid: 1353761065.856 agi_version: 10.3.1 agi_callerid: 100 agi_calleridname: IPphone-test agi_callingpres: 0 agi_callingani2: 0 agi_callington: 0 agi_callingtns: 0 agi_dnid: 1010 agi_rdnis: unknown agi_context: office agi_extension: 1010 agi_priority: 1 agi_enhanced: 0.0 agi_accountcode: agi_threadid: -1237062800 ENV LINE: agi_network: yes ENV LINE: agi_request: agi://127.0.0.1:26000 ENV LINE: agi_channel: SIP/IPphone-test-00000312 ENV LINE: agi_language: ru ENV LINE: agi_type: SIP ENV LINE: agi_uniqueid: 1353761065.856 ENV LINE: agi_version: 10.3.1 ENV LINE: agi_callerid: 100 ENV LINE: agi_calleridname: IPphone-test ENV LINE: agi_callingpres: 0 ENV LINE: agi_callingani2: 0 ENV LINE: agi_callington: 0 ENV LINE: agi_callingtns: 0 ENV LINE: agi_dnid: 1010 ENV LINE: agi_rdnis: unknown ENV LINE: agi_context: office ENV LINE: agi_extension: 1010 ENV LINE: agi_priority: 1 ENV LINE: agi_enhanced: 0.0 ENV LINE: agi_accountcode: ENV LINE: agi_threadid: -1237062800 ENV LINE: class AGI: self.env = {'agi_accountcode': '', 'agi_callerid': '100', 'agi_calleridname': 'IPphone-test', 'agi_callingani2': '0', 'agi_callingpres': '0', 'agi_callingtns': '0', 'agi_callington': '0', 'agi_channel': 'SIP/IPphone-test-00000312', 'agi_context': 'office', 'agi_dnid': '1010', 'agi_enhanced': '0.0', 'agi_extension': '1010', 'agi_language': 'ru', 'agi_network': 'yes', 'agi_priority': '1', 'agi_rdnis': 'unknown', 'agi_request': 'agi://127.0.0.1:26000', 'agi_threadid': '-1237062800', 'agi_type': 'SIP', 'agi_uniqueid': '1353761065.856', 'agi_version': '10.3.1'} COMMAND: VERBOSE "Test message from FastAGI" 1 VERBOSE "Test message from FastAGI" 1 RESULT_LINE: Traceback (most recent call last): File "/home/koqep/venv/aster/opt/pyst_manager/myagi.py", line 10, in <module> agi.verbose('Test message from FastAGI', verbose_level) File "/home/koqep/venv/aster/lib/python2.7/site-packages/pyst-0.4.38-py2.7.egg/asterisk/agi.py", line 566, in verbose self.execute('VERBOSE', self._quote(message), level) File "/home/koqep/venv/aster/lib/python2.7/site-packages/pyst-0.4.38-py2.7.egg/asterisk/agi.py", line 105, in execute return self.get_result() File "/home/koqep/venv/aster/lib/python2.7/site-packages/pyst-0.4.38-py2.7.egg/asterisk/agi.py", line 133, in get_result code = int(code) ValueError: invalid literal for int() with base 10: '' Connection closed by foreign host. 2012/11/24 Ralf Schlatterbeck <rs...@ru...> > On Fri, Nov 23, 2012 at 04:01:37PM +0600, Vladimir wrote: > > Hi everyone > > > > Please show example FastAGI server on pyst. > > Since FastAGI simply forwards all the data from standard input and > standard output via a TCP socket, you should be able to drop your Pyst > Code into a call from inetd on the remote machine, e.g. in > /etc/inetd.conf you'd write something like > > 4711 stream tcp nowait root /path/to/pyst/script > > and then call this from asterisk with somethink like > > exten => s,n,AGI(agi://192.168.0.2:4711) > > In this way you leave the FastAGI network-specific code to inetd and you > should be able to use your local AGI Pyst code unmodified on the remote > server. > > Ralf > -- > Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16 > Open Source Consulting www: http://www.runtux.com > Reichergasse 131, A-3411 Weidling email: of...@ru... > osAlliance member email: rs...@os... > |