Skip to content

[BUG] sockets_mgm module causes high CPU usage and "freezes" OpenSIPS #3789

@hizbi-github

Description

@hizbi-github

OpenSIPS version you are running

version: opensips 3.6.3 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, F_PARALLEL_MALLOC, DBG_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: d5222226a
main.c compiled on  with gcc 12

Describe the bug
Hi, the new sockets_mgm module seems to be causing high CPU usage and affecting the uptime of the OpenSIPS static UDP sockets as well as the dynamic sockets. Sometimes, OpenSIPS stops responding after I do a sockets_reload. Other times the issue occurs right at OpenSIPS start up. For the past few days I tried to manage it by restarting OpenSIPS whenever it freezed, and by freezing I mean it would stop responding even at the static 5060/5061 UDP/TLS sockets. Originally, I was doing mi(sockets_reload) in a timer route every 2 minutes, and I thought maybe the timer route was misbehaving, so I disabled the timer route and switched over to MI HTTP and did a sockets_reload once and the issue still occurred. Also, I noticed that when OpenSIPS freezes, both the opensips-cli through FIFO and MI HTTP stop working, I don't get any response at all.

I played around with the udp_workers and memory limits, but had no luck. I checked the GitHub issues and the mailing list, but didn't find anything related to this issue which makes sense as the sockets_mgm is a newer module so it's usage might not be as widespread.

By the way, thanks for the amazing piece of software and for the open source contributions!

To Reproduce

  1. Add two UDP sockets to the sockets table in the database.
  2. Start OpenSIPS, with sockets_mgm module.
  3. Either wait a little while, or issue a sockets_reload command.
  4. CPU usage will spike up and OpenSIPS will stop responding (htop screenshot attached).

Expected behavior
Allow the creation of new dynamic sockets and cleanup of old ones on sockets_reload/OpenSIPS startup without any abnormal CPU usage.

Relevant System Logs
On the debug level, I don't see anything specific logged related to this but I can grep you any specific pattern from the logs you need. Please let me know.

OS/environment information

  • Operating System: Debian GNU/Linux 12 (bookworm)
  • OpenSIPS installation: OpenSIPS version 3.6.3 from official APT repository
  • other relevant information: Intel(R) Xeon(R) CPU E5-2696 v4 @ 2.20GHz, 8 CPU Cores, 8 GB RAM, VMware hypervisor

Additional context
Another thing that I noticed is that sometimes, OpenSIPS will fail to route back a reply (like a 200-OK) from the dynamic socket. Restarting fixes it, but it can still happen while running. OpenSIPS will log the following (Please note that the 10.10.43.13 IP address is the actual destination where the 200-OK reply is expected to be routed, not the dynamic socket. There is a Cisco CUCM SIP server running at 10.10.43.13:5060 and it always accepts traffic and responds normally):

2025-12-20T13:21:21.055677+04:00 freeswitch /usr/sbin/opensips[108247]: ERROR:core:proto_udp_send: sendto(sock,0x7fa18a419488,467,0,0x7fa186d72550,16): Socket operation on non-socket(88) [10.10.43.13:5060]
2025-12-20T13:21:21.055931+04:00 freeswitch /usr/sbin/opensips[108247]: ERROR:tm:msg_send: send() to 10.10.43.13:5060 for proto udp/1 failed
2025-12-20T13:21:21.613415+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:core:proto_udp_send: sendto(sock,0x7fa185b0f280,467,0,0x7fa186d72550,16): Socket operation on non-socket(88) [10.10.43.13:5060]
2025-12-20T13:21:21.613790+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:tm:msg_send: send() to 10.10.43.13:5060 for proto udp/1 failed
2025-12-20T13:21:22.619632+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:core:proto_udp_send: sendto(sock,0x7fa185b0f280,467,0,0x7fa186d72550,16): Socket operation on non-socket(88) [10.10.43.13:5060]
2025-12-20T13:21:22.620158+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:tm:msg_send: send() to 10.10.43.13:5060 for proto udp/1 failed
2025-12-20T13:21:24.601315+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:core:proto_udp_send: sendto(sock,0x7fa185b0f280,467,0,0x7fa186d72550,16): Socket operation on non-socket(88) [10.10.43.13:5060]
2025-12-20T13:21:24.601757+04:00 freeswitch /usr/sbin/opensips[108259]: ERROR:tm:msg_send: send() to 10.10.43.13:5060 for proto udp/1 failed
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions