2017-08-20 4 views
0

J'ai utilisé un tutoriel en ligne pour exécuter un script Python en astérisque en utilisant AGI. Mais il retourne,Asterisk AGI Python Script terminé, retournant 0

AGI Script easy.py completed, returning 0 

J'ai donc activé le mode de débogage et obtenu une sortie.

AGI activé Debugging

== Using SIP RTP TOS bits 184 
== Using SIP RTP CoS mark 5  
-- Executing [[email protected]:1] Answer("SIP/OBITRUNK1-0000000b", "") 
in new stack 
-- Executing [[email protected]: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 is 'UNKNOWN' 
-- Executing [[email protected]: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 [[email protected]:1] Answer("SIP/OBITRUNK1-0000000c", "") 
in new stack 
-- Executing [[email protected]: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 is 'UNKNOWN'  

-- Executing [[email protected]: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 

code ci-dessus est ce que je suis quand je reçois un appel. De plus, il y a trois problèmes que je veux résoudre.

Problèmes

1) Cela montre

AGI Script easy.py completed, returning 0 

Et je ne sais pas pourquoi. Comme un forum en ligne a suggéré, j'ai même changé l'emplacement d'easy.py à /var/test/easy.py mais cela n'a pas fonctionné. Donc je veux résoudre ça car ça ne donne pas ce que j'attends.

Il s'agit d'un code easy.py. 2) Lorsque le téléphone sonne, vous pouvez voir easy.py exécuté deux fois. (Cela ne montre que deux fois mais quand il continue à sonner, il s'exécute en boucle). Je n'ai pas trouvé de solution pour ça. Aussi à partir de la deuxième boucle, il commence à montrer callerid comme OBITRUNK1.

3) Lorsque ce code est activé, mon téléphone fixe cesse de sonner, mais lorsque je supprime le code du fichier extensions.conf et que j'installe les codes extensions.conf standard, le téléphone fixe sonne normalement.

Remarque: Je sais que c'est faux. Mais comme ajouter des extensions à extensions_custom.conf ne fonctionnait pas, j'ai modifié le fichier extensions.conf. En fait, voici à quoi ressemble le fichier extensions.conf quand AGI fonctionne.

extensions.conf

from trunk: 
[from-trunk] 
exten => _X.,1,Answer() 
exten => _X.,n,AGI(/var/test/easy.py) 

quelqu'un l'espoir peut me aider. J'ai essayé de trouver des solutions pour eux dans plusieurs sites Web et livres, mais je n'ai pas eu de chance. Je vous remercie.

Répondre

1

Cela signifie que vous avez une erreur (syntaxe ou autre) dans votre script.

Veuillez noter que le débogage est oftoppic sur SO.

pour le script de débogage, premier astérisque arrêt

asterisk -rx "core stop now" 

Après que le lancer dans votre console

asterisk -vvvvgc 

et appelez

+0

Merci. J'ai essayé d'exécuter ces codes, mais j'ai reçu une erreur disant "pas de commande". – sam1234

+0

Ensuite, arrêtez astérisque (tuer safe_asterisk.sh, astérisque binaire, tout ce que vous avez sur votre système) et démarrez-le à partir de la console. Le problème est: les erreurs du script agi vont dans le handle STDERR et ne sont pas visibles sur la console astérisque, sauf si vous avez exécuté un astérisque lui-même dans cette console ssh. – arheops

+0

Merci. J'ai fait ce que vous avez dit et astérisque -vvvgc travaillé.Mais malheureusement, j'ai toujours ces problèmes. Pourtant, ce que j'ai mentionné dans ma question existe. Aidez-moi s'il vous plaît – sam1234