-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Test scenario:
Run:
$ perl -Ilib bin/answer_machine.pl -d 100 -W /tmp/test.pcmu -D /tmp/save sip:test@localhost:2000
And then via linphonec application create a SIP call to sip:test@localhost:2000. When Net::SIP::Simple::RTP tries to send packet it dies and exit whole answer_machine.pl script.
Reason is that linphonec uses localhost <--> localhost connection for SIP packets, but in SDP IN IP4 announces either public address or NATed address. Not the localhost address. And when Net::SIP::Simple::RTP::_send_rtp() calls send() function it fail because UDP packet from 127.0.0.1 to public IPv4 address is not possible to send.
So this is not a problem in answer_machine.pl, but in Net::SIP::Simple::RTP module. It should not die as this is not an error of Net::SIP, but error of other side (linphonec). Instead Net::SIP should exit active call.
To debug this problem I applied following patch:
diff --git a/lib/Net/SIP/Simple/RTP.pm b/lib/Net/SIP/Simple/RTP.pm
index d6cf418..7e3418a 100644
--- a/lib/Net/SIP/Simple/RTP.pm
+++ b/lib/Net/SIP/Simple/RTP.pm
@@ -384,13 +384,13 @@ sub _send_rtp {
}
die $! if ! defined $buf or $buf eq '';
- if (0) {
+# if (0) {
DEBUG(50, "%s -> %s seq=%d ts=%x",
- ip_sockaddr2string(getsockname($sock)),
- ip_sockaddr2string($addr),
+ Net::SIP::Util::ip_sockaddr2string(getsockname($sock)),
+ Net::SIP::Util::ip_sockaddr2string($addr),
$seq, $timestamp
);
- }
+# }
# add RTP header
$rtp_event = 0 if ! defined $rtp_event;
which shown me real problem in debug log:
1529101979.2434 DEBUG:<50> Net::SIP::Dispatcher::Eventloop::loop[172]: trigger timer(rtpsend) 1529101979.24203 repeat=0.02
1529101979.2435 DEBUG:<50> Net::SIP::Simple::RTP::_send_rtp[388]: 127.0.0.1:7616 -> X.X.X.X:7078 seq=1 ts=a0
1529101979.2436 DEBUG:<100> Net::SIP::Simple::RTP::_send_rtp[407]: send 160 bytes to RTP
Invalid argument at lib/Net/SIP/Simple/RTP.pm line 408.
1529101979.2438 DEBUG:<100> Net::SIP::Simple::Call::DESTROY[131]: done