MatheusBinicheski / agispeedy

Automatically exported from code.google.com/p/agispeedy
0 stars 0 forks source link

agispeedy调用agi失败 #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
测试版本:agispeedy 1.1 (php)
asterisk 版本 1.6.2.20
linux 版本:ubuntu 10.04
linux 内核:Linux ubuntu 2.6.32-21-generic

What steps will reproduce the problem?
1. 安装agispeedy
2. agispeedy直接send "hangup"
agi debug log:
root@ubuntu:/agispeedy# ./bin/agispeedy.php --verbose
[INFO][1331876622,1032]: Agispeedy - AGI ApplicationServer 1.1 starting...
[INFO][1331876622,1032][socket_open]: Services on 0.0.0.0:4573
[DEBUG][1331876622,1032][server_loop]: children 1034 created!
[DEBUG][1331876622,1032][server_loop]: children 1035 created!
[DEBUG][1331876622,1032][server_loop]: children 1036 created!
[DEBUG][1331876622,1032][server_loop]: children 1037 created!
[DEBUG][1331876623,1032][server_loop]: children 1038 created!
[DEBUG][1331876623,1032][server_loop]: children 1039 created!
[DEBUG][1331876623,1032][server_loop]: children 1040 created!
[DEBUG][1331876623,1032][server_loop]: children 1041 created!
[INFO][1331876662,1034][server_children_work]: catch one!
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1032][server_loop]: children 1151 created!
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[INFO][1331876662,1034][socket_read_response]: read (499)bytes end.
[INFO][1331876662,1034][socket_send_command]: Send "HANGUP"
[DEBUG][1331876662,1034][socket_read_response]: read a bit.
[INFO][1331876662,1034][socket_read_response]: read (13)bytes end.
[DEBUG][1331876662,1034][socket_send_command]: Received 200 result=1
[INFO][1331876662,1034][server_children_work]: exit!
[INFO][1331876692,1035][server_children_work]: catch one!
[DEBUG][1331876692,1035][socket_read_response]: read a bit.
[DEBUG][1331876692,1035][socket_read_response]: read a bit.
[INFO][1331876692,1035][socket_read_response]: read (499)bytes end.
[INFO][1331876692,1035][socket_send_command]: Send "HANGUP"
[DEBUG][1331876692,1032][server_loop]: children 1157 created!
[DEBUG][1331876692,1035][socket_read_response]: read a bit.
[INFO][1331876692,1035][socket_read_response]: read (13)bytes end.
[DEBUG][1331876692,1035][socket_send_command]: Received 200 result=1
[INFO][1331876692,1035][server_children_work]: exit!

3. 修改/agispeedy/bin/agispeedy.php 中的loadenviromentvars函数
修改为:
    function loadenviromentvars()
    {
        $szSocketRead=socket_read_response($this->sock,"\012\012");  //ENVIROMENT is \n\n end of
        $agienv = $this->envresult2array($szSocketRead);
        $this->input = $agienv[0];
        $this->param = $agienv[1];

        if (isset($this->input['agi_network_script'])==false)
            return(true);

        // fix scriptname if end with ?
        // check params in url mode like asterisk 1.4
        $agi_request = $this->input['agi_network_script'];
     if (strpos($agi_request,'?')!==false) {
            $fullname = explode("?",$agi_request);
            $this->scriptname = $fullname[0];
            //have params
            if (isset($fullname[1])) {
                foreach (explode("&",$fullname[1]) as $each) {
                    $kv = explode("=",$each);
                    if (count($kv) < 1)
                        continue;
                    $kv[0] = trim($kv[0]);
                    if (isset($kv[1])) {
                        $kv[1] = trim($kv[1]);
                        $this->param[$kv[0]]=$kv[1];
                    } else {
                        $this->param[$kv[0]]=null;
                    }
                }
            }
        }else {
                 $this->scriptname = $agi_request;
        }

Original issue reported on code.google.com by huw...@gmail.com on 16 Mar 2012 at 6:16

GoogleCodeExporter commented 8 years ago
1.2 final released to fixed this problem ,thank you

Original comment by hoowa.sun@gmail.com on 17 Mar 2012 at 2:52