<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi list:<br><br></div>I had a problem last days and I want to share with you how to solve it, just in case somebody has the same problem in the future. Devels, maybe is a good thing to publish in troubleshoting page.<br><br></div>I started to see in a Opensips 1.11.9 log tons of messages with this text:<br><br>ERROR:core:handle_new_connect: failed to accept connection(24): Too many open files<br><br></div>This is a TLS enabled proxy, the vast majority of clients connect to it using TLS protocol, and the AORs population is about 1000 users.<br><br></div>I thought about kernel FD limits, but checking generic kernel limits seems the value is too high.<br><br> You can check the open files used by opensips TCP main process using something like "ls -la /proc/PID/fd | wc -l" and check the limit for a specific process using "cat /proc/PID/limits" <br><br></div>Checking the specific limits of the TCP main process, I can see the limit for "max open files" is 1024 how is this possible?<br><br></div>The reason is I'm using systemd to launch Opensips, and systemd completely ignores global kernel limits.<br><br></div>The solution is to put the limit in systemd init file, something like this inside [service] section:<br>LimitNOFILE=49152<br><br></div>This is my complete systemd init file, if somebody find it useful.<br><br><br>[Unit]<br>Description=Opensips Sip server<br>After=network.target<br>After=mediaproxy-dispatcher.service<br><br>[Service]<br>Type=forking<br>TimeoutSec=10s<br>LimitNOFILE=49152<br>PIDFile=/var/run/opensips/opensips.pid<br>ExecStartPre=/bin/mkdir -p /var/run/opensips<br>ExecStartPre=/bin/chmod 775 /var/run/opensips<br>ExecStartPre=/bin/chown opensips.opensips /var/run/opensips<br>ExecStartPre=/usr/sbin/opensips -c<br>ExecStart=/usr/sbin/opensips -P /var/run/opensips/opensips.pid -m 192 -M 16 -u opensips -g opensips<br>Restart=always<br><br><br><br>[Install]<br>WantedBy=multi-user.target<br><br></div>Later do a systemctl daemon-reload and restart opensips service. The new limits are applied now. <br><div><br><div><div><div><div><div><div>Hope this can help somebody with my problem in the future.<br><br></div><div>Regards,<br><br></div><div>Carlos Oliva<br clear="all"></div><div><div><div><div><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">    <br></div><table cellspacing="0" cellpadding="0" border="0" width="600"><tbody><tr><td width="1%" valign="top"><br></td><td align="center" width="33%" valign="top"><br></td><td align="left" width="2%" valign="top"><br></td><td width="71%" valign="top"><br></td></tr></tbody></table></div></div></div></div></div></div>
</div></div></div></div></div></div></div></div></div></div></div>