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

2

6

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();
    }
}
Abutilon answered 14/9, 2013 at 3:39 Comment(0)
V
7

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.

Vergne answered 15/11, 2013 at 13:20 Comment(1)
Yes! Thats the case. Asterisk generates a result message for every command send in and expects this to be handled by the agi script. If the script didn't read the returned result asterisk throws the ERROR above.Hyperbolism
T
-3

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.

Trinomial answered 15/10, 2013 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.