Asterisk SIP/TLS: “Too many open files”

Hi all,

I’m running Asterisk 20.11.0 on Linux with PJSIP. About once a week, my SIP trunk with Etisalat stops responding, and both inbound/outbound calls fail.

When this happens, I see the following repeating error in the logs:
[Aug 25 08:59:30] ERROR[563033]: tcptls.c:306 ast_tcptls_server_root: TCP/TLS accept failed: Too many open files

After this, Asterisk is still running, but the trunk will not re-register, and calls don’t work. The only way to recover is to restart the SIP server (reboot or restart Asterisk).

My questions:

  1. Is this caused by Asterisk hitting the Linux file descriptor limit (ulimit)?

  2. Should I increase limits in /etc/security/limits.conf or systemd service file for asterisk?

  3. Is there a known memory or socket leak in res_pjsip or WebSocket (I also use WebRTC clients)?

  4. Would switching the transport to UDP (instead of WS/TLS) for some endpoints help reduce open file usage?

Environment details:

  • Asterisk version: 20.11.0

  • Using PJSIP with WebSocket (WS) + UDP transports

  • Realtime config with PostgreSQL

  • Trunk: Etisalat (requires registration)

Has anyone experienced “Too many open files” errors leading to SIP registration failure? What’s the best practice to handle this—should I raise the open file limit, or investigate if Asterisk/WebRTC sessions are not closing properly?

Thanks in advance,
Manoj

show result

lsof -a -p 3928081(Asterisk pid)

and can see many

(CLOSE_WAIT) connections

You can get an idea of the files a process has open by looking in its/proc/pid/fddirectory.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.