Asterisk Java AGI:utils.c write() 返回错误:管道损坏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18798021/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 11:09:55  来源:igfitidea点击:

Asterisk Java AGI: utils.c write() returned error: Broken pipe

javaasteriskagi

提问by Jason

I have written a hello world Asterisk AGI script using Java. The script runs as expected and plays the hello world sound file, but the asterisk console is giving an error though:

我已经使用 Java 编写了一个 hello world Asterisk AGI 脚本。该脚本按预期运行并播放 hello world 声音文件,但 asterisk 控制台给出了一个错误:

ERROR[31058]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe

错误 [31058]:utils.c:1164 ast_carefulwrite:write() 返回错误:管道损坏

Any idea what I'm doing wrong?

知道我做错了什么吗?

I'm using asterisk-java-0.3.1.jar and Asterisk 1.8.10.1~dfsg-1ubuntu1

我正在使用 asterisk-java-0.3.1.jar 和 Asterisk 1.8.10.1~dfsg-1ubuntu1

Java class as below:

Java类如下:

import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;

public class AgiHelloWorld extends BaseAgiScript 
{
    @Override
    public void service(AgiRequest arg0, AgiChannel arg1) throws AgiException 
    {
        answer();
        streamFile("hello-world");
        hangup();
    }
}

采纳答案by gkocjan

This error occurs when Asterisk tries to write some line to your AGI/FastAGI after script finish execution.

当 Asterisk 在脚本执行完成后尝试向 AGI/FastAGI 写入一些行时,会发生此错误。

Usually, asterisk send headers, and then waits for commands. After each command asterisk sends a response. But here is one exception, at the and it writes on more line

通常,星号发送标头,然后等待命令。在每个命令后星号发送一个响应。但这里有一个例外,它写在更多行上

HANGUP

I think it is the line asterisk can`t write in your case. You can check it by turning on agi debug. Write in the console:

我认为这是星号不能在你的情况下写的行。您可以通过打开 agi debug 来检查它。在控制台写:

agi set debug on

and then after running your script you should see something like this:

然后在运行您的脚本后,您应该看到如下内容:

    -- <SIP/XXXX-0000007c>AGI Script YOUR_AGI_NAME completed, returning 4
<SIP/XXXX-0000007c>AGI Tx >> HANGUP
ERROR[1502]: utils.c:1232 ast_carefulwrite: write() returned error: Broken pipe

You can see that asterisk try to send HANGUP after script completed. You don`t have to worry about it, but it is a library bug.

您可以看到星号在脚本完成后尝试发送 HANGUP。你不必担心它,但它是一个库错误。

回答by Ravikiran Reddy

This is error is generally occurred when you don't have access permission, Please log in as the root user and try you will be successful.

这个错误一般是在没有访问权限的情况下出现的,请以root用户登录试试就可以成功。