Most units require or tolerate CRLF as the terminator
Using only \r causes many including 3M units to signal errors
due to delay this resets CRLF to be default but adds a single
constant variable and explanation so that if you have a
"strictly conforming" unit (the 'Baby' is the only I have encountered
you know where to make the change
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
use warnings;
use English;
use Exporter;
use warnings;
use English;
use Exporter;
use Sys::Syslog qw(syslog);
use POSIX qw(strftime);
use Sys::Syslog qw(syslog);
use POSIX qw(strftime);
our $error_detection = 0;
our $protocol_version = 1;
our $error_detection = 0;
our $protocol_version = 1;
-our $field_delimiter = '|'; # Protocol Default
+our $field_delimiter = '|'; # Protocol Default
+# The message terminator for a SIP message is '\r' in the standard doc
+# However most sip devices in the wild send a CR LF pair
+# This is required by Telnet if that is your carrier mechanism
+# On raw connections it may also be required because the buffer is
+# only flushed on linefeed and its absence causes enough delay for
+# client machines to go into an error state
+# The below works for almost all machines if however you have one
+# which does not like the additional linefeed change value to $CR
+Readonly my $msg_terminator => $CRLF;
# We need to keep a copy of the last message we sent to the SC,
# in case there's a transmission error and the SC sends us a
# We need to keep a copy of the last message we sent to the SC,
# in case there's a transmission error and the SC sends us a
if ($file) {
$file->autoflush(1);
if ($file) {
$file->autoflush(1);
+ print $file $msg, $msg_terminator;
} else {
STDOUT->autoflush(1);
} else {
STDOUT->autoflush(1);
+ print $msg, $msg_terminator;
syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
}
syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
}