Open kobaz opened 1 month ago
I've been unable to reproduce this more than just a few times. Hasn't happened since last week. I'll add more debugging just in case!
Found the problem. ipv6 causes slowdowns when ipv6 is not available.
Disabling ipv6 makes my test case twice as fast!
--- a/LIB/x64-perl5.28/perl/lib/perl5/Net/SIP/Util.pm
+++ b/LIB/x64-perl5.28/perl/lib/perl5/Net/SIP/Util.pm
@@ -19,7 +19,11 @@ use Net::SIP::Debug;
use Carp qw(confess croak);
use base 'Exporter';
+our $IPV6_ENABLE;
+
BEGIN {
+ $IPV6_ENABLE = 1; # We'll assume we can do v6 until our tests say otherwise
+
my $mod6 = '';
if (eval {
require IO::Socket::IP;
@@ -70,7 +74,7 @@ BEGIN {
*AF_INET6 = sub() { -1 };
}
- *CAN_IPV6 = $mod6 ? sub() { 1 } : sub() { 0 };
+ *CAN_IPV6 = $mod6 ? sub() { $IPV6_ENABLE; } : sub() { 0 };
Socket->import(qw(unpack_sockaddr_in6 pack_sockaddr_in6)) if $mod6;
}
@@ -472,6 +476,7 @@ sub create_rtp_sockets {
###########################################################################
sub invoke_callback {
my ($cb,@more_args) = @_;
+
if ( UNIVERSAL::isa( $cb,'CODE' )) {
# anon sub
return $cb->(@more_args)
@@ -765,6 +770,11 @@ sub mime_parse {
return $p;
}
+# Allow specific disable of IPv6 even if the local system is capable
+sub ipv6 {
+ $IPV6_ENABLE = $_[1];
+}
+
package Net::SIP::Utils::_MIME;
use fields qw(ct ctparam hdr body preamble parts postparts eol);
Net::SIP::Util->import(qw(sip_hdrval2parts));
Usage:
Net::SIP::Util->ipv6(0);
my $ua = Net::SIP::Simple->new(....
This allows for disabling or re-enabling ipv6 at run-time depending on needs
I have a different proposal, which a) reuses the already optionally exported CAN_IPV6 function to set the value (i.e. no different functions) and b) gets called as function not method, like all other subroutines in Utils. I did not test it yet, so please check if it works. optionally-disable-ipv6.txt
Thanks, I will check.
Also, I saw your old message (since deleted), about properly configured IPV6. In a perfect world: yes But in an imperfect world, for instance a service is ipv4 only.
Example: sip.clearip.com. IN AAAA is empty result.
This is an ipv4-only service.
Sometimes the query for AAAA takes 2-3 seconds waiting for a result we KNOW will be empty. So, why not skip it. My sip test is now 100ms instead of 200ms by skipping ipv6 dns lookups
Also... considering this is a long-running service processing many requests (we're making 2 SIP calls per second). We should cache DNS lookups.
Can Net::SIP cache dns? Or maybe I should override the dns resolver and provide my own local-cache DNS?
I have implemented DNS cache, so hopefully this should solve the rest of this for me. My goal: Process each call in less than 5 seconds with the ideal target of 100ms If the call cannot finish in 5 seconds this is a fail. We want to avoid this.
Now there's only one last issue to fix for our situation, which is when prio is missing -- #68
From the running system shell:
But, and not always, but randomly there will be a big delay (2-5 seconds)
Notice: resolve_uri 1722959154.2142 to 1722959156.2161 = 2.0019 seconds