"Socket has unexpectedly been closed" - MariaDB nodejs connector on UCP

I installed the UCP module on FreePBX 17 with Asterisk 22. When I try to start the UCP Daemon, it fails with an error, and in the logs I see the following message:

2025-10-10 14:12 +02:00: SqlError: (conn:48072, no: 45009, SQLState: 08S01) socket has unexpectedly been closed
2025-10-10 14:12 +02:00:     at module.exports.createFatalError (/var/www/html/admin/modules/ucp/node/node_modules/mariadb/lib/misc/errors.js:90:10)
2025-10-10 14:12 +02:00:     at Connection.socketErrorHandler (/var/www/html/admin/modules/ucp/node/node_modules/mariadb/lib/connection.js:1518:20)
2025-10-10 14:12 +02:00:     at Socket.emit (node:events:529:35)
2025-10-10 14:12 +02:00:     at endReadableNT (node:internal/streams/readable:1400:12)
2025-10-10 14:12 +02:00:     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
2025-10-10 14:12 +02:00:   sqlMessage: 'socket has unexpectedly been closed',
2025-10-10 14:12 +02:00:   sql: null,
2025-10-10 14:12 +02:00:   fatal: true,
2025-10-10 14:12 +02:00:   errno: 45009,
2025-10-10 14:12 +02:00:   sqlState: '08S01',
2025-10-10 14:12 +02:00:   code: 'ER_SOCKET_UNEXPECTED_CLOSE'
2025-10-10 14:12 +02:00: }

Command: sudo fwconsole start ucp -vvv

Running FreePBX startup...
Taking too long? Customize the chown command, See https://sangomakb.atlassian.net/wiki/spaces/FP/pages/10289397/FreePBX+Chown+Conf
Setting Permissions...
Setting base permissions...Done in 1 seconds
Setting specific permissions...
Finished setting permissions
Unable to run Pre-Asterisk hooks, because Asterisk is already running on PID 2468 and has been running for 45 minutes, 32 seconds
Running Asterisk post from Ucp module
Starting UCP Node Server...
[->--------------------------] 1 sec
Started UCP Node Server. PID is 17955

Command: sudo -u asterisk fwconsole pm2 --list

+--------------+-----+---------+----------+--------+-----+-------+
| Process Name | PID | Status  | Restarts | Uptime | CPU | Mem   |
+--------------+-----+---------+----------+--------+-----+-------+
| ucp          | 0   | errored | 15       | 0      | 0%  | 0.00B |
+--------------+-----+---------+----------+--------+-----+-------+

Thank you in advance for your help.

You are trying to start Asterisk when it hasn’t fully shutdown from the last run.

I issued the following commands.

sudo npm install mariadb
sudo fwconsole ma downloadinstall ucp
sudo -u asterisk fwconsole ma downloadinstall ucp
sudo fwconsole ma listonline
sudo fwconsole start ucp

Now UCP is starting up, but only for a few seconds

sudo fwconsole start ucp -vvv
Running FreePBX startup...
Taking too long? Customize the chown command, See https://sangomakb.atlassian.net/wiki/spaces/FP/pages/10289397/FreePBX+Chown+Conf
Setting Permissions...
Setting base permissions...Done in 1 seconds
Setting specific permissions...
Finished setting permissions
Unable to run Pre-Asterisk hooks, because Asterisk is already running on PID 178175 and has been running for 9 minutes, 15 seconds
Running Asterisk post from Ucp module
Starting UCP Node Server...
[->--------------------------] < 1 sec
Started UCP Node Server. PID is 183346

sudo fwconsole pm2 --list
+--------------+--------+--------+----------+-----------+-----+---------+
| Process Name | PID    | Status | Restarts | Uptime    | CPU | Mem     |
+--------------+--------+--------+----------+-----------+-----+---------+
| ucp          | 183571 | online | 7        | 2 seconds | 0%  | 45.82MB |
+--------------+--------+--------+----------+-----------+-----+---------+
sudo fwconsole pm2 --list
+--------------+--------+--------+----------+-----------+-----+---------+
| Process Name | PID    | Status | Restarts | Uptime    | CPU | Mem     |
+--------------+--------+--------+----------+-----------+-----+---------+
| ucp          | 183774 | online | 14       | 4 seconds | 0%  | 44.18MB |
+--------------+--------+--------+----------+-----------+-----+---------+
sudo fwconsole pm2 --list
+--------------+-----+---------+----------+--------+-----+-------+
| Process Name | PID | Status  | Restarts | Uptime | CPU | Mem   |
+--------------+-----+---------+----------+--------+-----+-------+
| ucp          | 0   | errored | 15       | 0      | 0%  | 0.00B |
+--------------+-----+---------+----------+--------+-----+-------+

The problem lay in my network architecture [Asterisk/FreePBX → ProxySQL → MariaDB]. It turned out that ProxySQL was not parsing all queries becauseit considered them invalid. After restructuring the architecture [Asterisk/FreePBX → MariaDB], UCP works. However, despite installing it via the panel, it still needs to be reinstalled through the console.

sudo npm install mariadb
sudo fwconsole ma downloadinstall ucp
sudo fwconsole start ucp
sudo fwconsole pm2 --list

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