[Home]

Summary:ASTERISK-15124: ERROR[24164]: utils.c:966 ast_carefulwrite: write() returned error: Broken pipe
Reporter:marcus1981-2 (marcus1981-2)Labels:
Date Opened:2009-11-12 03:10:03.000-0600Date Closed:2011-06-07 14:08:21
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:When I execute an AGI Script which performs several operations, e.g. database-operations I get the error

"ERROR[24164]: utils.c:966 ast_carefulwrite: write() returned error: Broken pipe"

almost every time, resulting the database-operation nit to be performed at all. it happens, if i call the AGI really often, lest say 10 times a second.

sometime the agi executes correctly but most times not.

i didnt got that error an Version 1.4.13 and it apears after upgrading to 14.25.1.




****** ADDITIONAL INFORMATION ******

here my context and agi script:

context /dialplan:

exten => _X.,n,AGI(status.agi|ochst|${host}|${user}|${passwd}|CONNECTING|9|${nid}|${ME}|0|0|${noanswer}|${busy}|${j_machine}|${interval})


AGI script:

#!/usr/bin/perl -w

use strict;
use DBI();
use Switch;
$|=1;

unless (@ARGV >= 6) {
       usage () ;
       exit (0) ;
}
my ($db, $host, $user, $pwd, $MSG, $stat, $jobid, $ME,$versuche,$dur,$delay1,$delay2,$delay3,$delay4,$min_dur,$pos) = @ARGV;
my $sql = "update `$db`.`nummern_kopie` set `n_clearcode`=if(n_clearcode='MACHINE','MACHINE','$MSG')";
my $delay="0";
my $next_pos_sql="";
my $dur_sql="";
#unless($delay3)
#{
#$delay3=0;
#}
switch ($MSG)
{
       case "NOANSWER"
       {
       $delay=$delay1;
       }

       case "BUSY"
       {
       $delay=$delay2;
       }

       case "CONGESTION"
       {
       $delay=$delay2;
       }
       case "ANSWER"
       {
       $delay=$delay4;
       }

       else
       {
        #do nothing
        $delay=$delay1;
       }


}
if($pos =="1")
{
       $dur_sql=",dur=$dur ";
}
elsif($pos=="2")
{
       $dur_sql=",dur2=$dur ";
}
if ( $dur >= $min_dur)
{
       $next_pos_sql=",n_nextpos=anzahl_erfolg+1 ";
}

$sql .= ",`n_status`=if(n_clearcode='MACHINE','0','$stat'), n_maschine=$ME, n_lastcall=NOW(), n_anzvers=if('$MSG'='ANSWER','0',if($versuche>0,$versuche,n_anzvers)), n_nextcall=if(n_clearcode='MACHINE',DATE_ADD(NOW(), INTERVAL $delay3 SECOND),DATE_ADD(NOW(), INTERVAL $delay SECOND)), anzahl_erfolg=if('$MSG'='ANSWER',anzahl_erfolg+1,anzahl_erfolg) $next_pos_sql $dur_sql  where `nid`=$jobid";
print "sdl: $sql";
my $dbh = DBI->connect("dbi:mysql:database=$db;host=$host;port=3306",$user, $pwd);
unless($dbh) {
 print(STDERR "Fehler beim Aufbau der ", "Datenbankverbindung ($DBI::errstr)\n");
 system("echo `date`:$DBI::errstr >> /var/log/asterisk/error.log");
 exit(1);
}
$dbh->do($sql);

$dbh->disconnect();

sub usage {
       print("USAGE:\n");
       print("$0 <DB> <HOST> <USER> <PASSWD> <MSG> <STAT> <JOBID> <MASCHINEID>\n");
}
END {
 if($dbh) { $dbh->disconnect(); }
}

exit( 0 );

1;
Comments:By: Nicholas Blasgen (nblasgen) 2009-11-12 10:59:35.000-0600

I'm also having this issue on Asterisk 1.4.23.1.  Oddly enough this machine has been perfect for 6 months or so.  Then all of a sudden today I change the RealTime Database to be remote from the locally hosted version.  Now every single AGI script (or the AGI scrips I end up running) cause a Broken Pipe upon connection.

Ah, but never mind!  I turn on AGI debug and there is a BUG :)

AGI Rx << Fatal error: Call to a member function query() on a non-object in /var/www/html/cli/ajax.php on line 15
AGI Tx >> 510 Invalid or unknown command
[Nov 12 08:52:25] ERROR[4116]: utils.c:966 ast_carefulwrite: write() returned error: Broken pipe

So it seems, at least for me, no bug.

By: Leif Madsen (lmadsen) 2009-11-13 08:11:12.000-0600

Could you report the AGI debug when this happens like the other note here that mentions he doesn't have a bug in Asterisk, but is rather an issue with the AGI script since he is missing a function?

Perhaps it's something like that?

By: marcus1981-2 (marcus1981-2) 2009-11-13 09:22:12.000-0600

you're right. if the agi returns a string which is not a valid command this error appears. it is no bug but a bit confusing, cause i was used to return text-messages to asterisk for debuging and loging purposes.

but even if no plain-text is returned, some agi-scripts causes this error. what is the right way to exit an AGI? in perl i use exit(1) and in sh (bin/bash) also. but in one of the two cases the error raises still.

thanks  a lot so far.

By: Leif Madsen (lmadsen) 2009-11-13 10:37:46.000-0600

I'm going to suggest you use the asterisk-users mailing list for your questions as I'm not able to provide an answer to the question you're asking.

I'm also going to close this issue as it is not a bug. Thanks for following up!