<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi guys, <div class="">Iam running outbound socket in a server, and It start perfect and receive 265 calls, which mean 265 pid created by outbound socket.</div><div class="">The problem is in that exactly moment, the server get memory ram out and get freezes.</div><div class="">I can see each pid of outbound socket there:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382843] [16701] 0 16701 10032 846 25 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382845] [16704] 0 16704 26451 2463 27 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382846] [16709] 0 16709 10094 898 23 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382848] [16711] 0 16711 11686 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382849] [16715] 0 16715 10067 882 23 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382851] [16720] 0 16720 11686 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382852] [16725] 0 16725 11694 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382854] [16730] 0 16730 11686 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382855] [16736] 0 16736 10094 898 23 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382857] [16738] 0 16738 11688 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382858] [16743] 0 16743 11686 2486 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382860] [16748] 0 16748 11686 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382861] [16754] 0 16754 11694 2488 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382863] [16756] 0 16756 11694 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382864] [16761] 0 16761 11686 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382866] [16766] 0 16766 10085 898 23 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382867] [16771] 0 16771 11688 2489 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382868] [16775] 0 16775 11694 2498 24 0 0 outbound_socket</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.382870] [16777] 0 16777 11686 2498 24 0 0 outbound_socket</div></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">And continues……</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">At the end:</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><b class="">Feb 6 21:14:57 </b>test-server<b class=""> kernel: [97024.383243] Out of memory: Kill process 14314 (freeswitch) score 28 or sacrifice child</b></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Feb 6 21:14:57 test-server kernel: [97024.384424] Killed process 14314 (freeswitch) total-vm:1282524kB, anon-rss:58856kB, file-rss:0kB</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">I use this code.</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(197, 134, 192);">require</span> ESL;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(197, 134, 192);">use</span> IO::Socket::INET;</div><br class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$ip</span> = <span class="" style="color: rgb(206, 145, 120);">"127.0.0.1"</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$sock</span> = new IO::Socket::INET ( LocalHost => <span class="" style="color: rgb(156, 220, 254);">$ip</span>, LocalPort => <span class="" style="color: rgb(206, 145, 120);">'8083'</span>, Proto => <span class="" style="color: rgb(206, 145, 120);">'tcp'</span>, Listen => 1, Reuse => 1 );</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(197, 134, 192);">die</span> <span class="" style="color: rgb(206, 145, 120);">"Could not create socket: </span><span class="" style="color: rgb(156, 220, 254);">$!</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span> <span class="" style="color: rgb(197, 134, 192);">unless</span> <span class="" style="color: rgb(156, 220, 254);">$sock</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(197, 134, 192);">for</span>(;;) {</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$new_sock</span> = <span class="" style="color: rgb(156, 220, 254);">$sock</span>->accept();</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$pid</span> = <span class="" style="color: rgb(220, 220, 170);">fork</span>();</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(197, 134, 192);">if</span> (<span class="" style="color: rgb(156, 220, 254);">$pid</span>) {</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">print</span> <span class="" style="color: rgb(206, 145, 120);">"New child pid </span><span class="" style="color: rgb(156, 220, 254);">$pid</span><span class="" style="color: rgb(206, 145, 120);"> created...</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">close</span>(<span class="" style="color: rgb(156, 220, 254);">$new_sock</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(197, 134, 192);">next</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> }</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$fd</span> = <span class="" style="color: rgb(220, 220, 170);">fileno</span>(<span class="" style="color: rgb(156, 220, 254);">$new_sock</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$con</span> = new ESL::ESLconnection(<span class="" style="color: rgb(156, 220, 254);">$fd</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$info</span> = <span class="" style="color: rgb(156, 220, 254);">$con</span>->getInfo();</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$uuidLegB</span> = <span class="" style="color: rgb(156, 220, 254);">$info</span>->getHeader(<span class="" style="color: rgb(206, 145, 120);">"unique-id"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(96, 139, 78);">#This $uuidLegA is a temp variable where I store uuid leg A for post bridge</span></div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"><span class="" style="color: rgb(86, 156, 214);"> my</span> <span class="" style="color: rgb(156, 220, 254);">$uuidLegA</span> = <span class="" style="color: rgb(156, 220, 254);">$info</span>->getHeader(<span class="" style="color: rgb(206, 145, 120);">"variable_outbound_caller_id_name"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$joinUUID</span> = <span class="" style="color: rgb(206, 145, 120);">'resp'</span>.<span class="" style="color: rgb(156, 220, 254);">$uuidLegA</span>.<span class="" style="color: rgb(206, 145, 120);">'|'</span>.<span class="" style="color: rgb(156, 220, 254);">$uuidLegB</span>.<span class="" style="color: rgb(206, 145, 120);">' XML default'</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">print</span>(<span class="" style="color: rgb(206, 145, 120);">"UUID Leg A is </span><span class="" style="color: rgb(156, 220, 254);">$uuidLegA</span><span class="" style="color: rgb(206, 145, 120);"> and B is </span><span class="" style="color: rgb(156, 220, 254);">$uuidLegB</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$con</span>->events(<span class="" style="color: rgb(206, 145, 120);">"plain"</span>,<span class="" style="color: rgb(206, 145, 120);">"all"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$con</span>->execute(<span class="" style="color: rgb(206, 145, 120);">"spandsp_start_tone_detect"</span>,<span class="" style="color: rgb(206, 145, 120);">"34"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$connectedSession</span> = 1;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> </div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(197, 134, 192);">while</span>(<span class="" style="color: rgb(156, 220, 254);">$con</span>->connected() & <span class="" style="color: rgb(156, 220, 254);">$connectedSession</span> == 1) {</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$e</span> = <span class="" style="color: rgb(156, 220, 254);">$con</span>->recvEvent();</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$ev_name</span> = <span class="" style="color: rgb(156, 220, 254);">$e</span>->getHeader(<span class="" style="color: rgb(206, 145, 120);">"Event-Name"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">print</span>(<span class="" style="color: rgb(206, 145, 120);">"</span><span class="" style="color: rgb(156, 220, 254);">$ev_name</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(197, 134, 192);">if</span>(<span class="" style="color: rgb(156, 220, 254);">$ev_name</span> <span class="" style="color: rgb(220, 220, 170);">eq</span> <span class="" style="color: rgb(206, 145, 120);">'DETECTED_TONE'</span>){</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(86, 156, 214);">my</span> <span class="" style="color: rgb(156, 220, 254);">$tone_name</span> = <span class="" style="color: rgb(156, 220, 254);">$e</span>->getHeader(<span class="" style="color: rgb(206, 145, 120);">"Detected-Tone"</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">print</span> <span class="" style="color: rgb(206, 145, 120);">"DETECTED_TONE [</span><span class="" style="color: rgb(156, 220, 254);">$tone_name</span><span class="" style="color: rgb(206, 145, 120);">]</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span>; </div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(197, 134, 192);">if</span> (<span class="" style="color: rgb(156, 220, 254);">$tone_name</span> <span class="" style="color: rgb(220, 220, 170);">eq</span> <span class="" style="color: rgb(206, 145, 120);">'RING_TONE'</span>) {</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$command</span> = <span class="" style="color: rgb(206, 145, 120);">'spandsp_stop_tone_detect '</span>.<span class="" style="color: rgb(156, 220, 254);">$uuidLegB</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$con</span>->api(<span class="" style="color: rgb(156, 220, 254);">$command</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$con</span>->execute(<span class="" style="color: rgb(206, 145, 120);">"transfer"</span>,<span class="" style="color: rgb(156, 220, 254);">$joinUUID</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(156, 220, 254);">$connectedSession</span> = 0;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> } </div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> }</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> }</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">print</span> <span class="" style="color: rgb(206, 145, 120);">"BYE</span><span class="" style="color: rgb(215, 186, 125);">\n</span><span class="" style="color: rgb(206, 145, 120);">"</span>;</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);"> <span class="" style="color: rgb(220, 220, 170);">close</span>(<span class="" style="color: rgb(156, 220, 254);">$new_sock</span>);</div><div class="" style="color: rgb(212, 212, 212); font-family: Menlo, Monaco, "Courier New", monospace; white-space: pre; background-color: rgb(30, 30, 30);">}</div></div></div></body></html>