[Freeswitch-users] Outbound Socket isn't killing each pid

Raimundo Pérez Nieves raimundo.perez.cuba at gmail.com
Wed Feb 7 12:47:50 UTC 2018


Hi guys, 
Iam running outbound socket in a server, and It start perfect and receive 265 calls, which mean 265 pid created by outbound socket.
The problem is in that exactly moment, the server get memory ram out and get freezes.
I can see each pid of outbound socket there:

Feb  6 21:14:57 test-server kernel: [97024.382843] [16701]     0 16701    10032      846      25        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382845] [16704]     0 16704    26451     2463      27        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382846] [16709]     0 16709    10094      898      23        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382848] [16711]     0 16711    11686     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382849] [16715]     0 16715    10067      882      23        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382851] [16720]     0 16720    11686     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382852] [16725]     0 16725    11694     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382854] [16730]     0 16730    11686     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382855] [16736]     0 16736    10094      898      23        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382857] [16738]     0 16738    11688     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382858] [16743]     0 16743    11686     2486      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382860] [16748]     0 16748    11686     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382861] [16754]     0 16754    11694     2488      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382863] [16756]     0 16756    11694     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382864] [16761]     0 16761    11686     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382866] [16766]     0 16766    10085      898      23        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382867] [16771]     0 16771    11688     2489      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382868] [16775]     0 16775    11694     2498      24        0             0 outbound_socket
Feb  6 21:14:57 test-server kernel: [97024.382870] [16777]     0 16777    11686     2498      24        0             0 outbound_socket
And continues……

At the end:
Feb  6 21:14:57 test-server kernel: [97024.383243] Out of memory: Kill process 14314 (freeswitch) score 28 or sacrifice child
Feb  6 21:14:57 test-server kernel: [97024.384424] Killed process 14314 (freeswitch) total-vm:1282524kB, anon-rss:58856kB, file-rss:0kB


I use this code.

require ESL;
use IO::Socket::INET;

my $ip = "127.0.0.1";
my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort => '8083',  Proto => 'tcp',  Listen => 1,  Reuse => 1 );
die "Could not create socket: $!\n" unless $sock;
for(;;) {
  my $new_sock = $sock->accept();
  my $pid = fork();
  if ($pid) {
  print "New child pid $pid created...\n";
    close($new_sock);
    next;
  }
  my $fd = fileno($new_sock);
  my $con = new ESL::ESLconnection($fd);
  my $info = $con->getInfo();
  my $uuidLegB = $info->getHeader("unique-id");
  #This $uuidLegA is a temp variable where I store uuid leg A for post bridge
  my $uuidLegA = $info->getHeader("variable_outbound_caller_id_name");
  my $joinUUID = 'resp'.$uuidLegA.'|'.$uuidLegB.' XML default';
  print("UUID Leg A is $uuidLegA and B is $uuidLegB\n");
  $con->events("plain","all");
  $con->execute("spandsp_start_tone_detect","34");
  my $connectedSession = 1;
  
  while($con->connected() & $connectedSession == 1) {
    my $e = $con->recvEvent();
    my $ev_name = $e->getHeader("Event-Name");
    print("$ev_name\n");
    if($ev_name eq 'DETECTED_TONE'){
      my $tone_name = $e->getHeader("Detected-Tone");
      print "DETECTED_TONE [$tone_name]\n";  
      if ($tone_name eq 'RING_TONE') {
        $command = 'spandsp_stop_tone_detect '.$uuidLegB;
        $con->api($command);
        $con->execute("transfer",$joinUUID);
        $connectedSession = 0;
      } 
    }
  }
  print "BYE\n";
  close($new_sock);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20180207/b1d15311/attachment-0001.html>


More information about the FreeSWITCH-users mailing list