문제

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:

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

Any idea what I'm doing wrong?

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

Java class as below:

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();
    }
}
도움이 되었습니까?

해결책

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

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 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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top