Fix db_port config in services-wrapper

Hello All,

I’m facing an issue with " Fix db_port config in services-wrapper (#11284)" The fix does not resolve the issue when db port is set in configuration:

/opt/librenms/services-wrapper.py
ERROR: Could not connect to MySQL database!

I removed the db_port from config.php for this to work.

====================================

Component Version
LibreNMS 1.62.2
DB Schema 2020_03_24_0844_add_primary_key_to_device_graphs (160)
PHP 7.3.16
MySQL 5.5.64-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

====================================

[OK] Composer Version: 1.10.1
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

I have this setting in my config.php file:

Database config

$config[‘db_host’] = ‘db-host’;
$config[‘db_port’] = 3306;

What was your db_port setting?
Are you sure you have the latest version of the service-wrapper?

Hello, I have the same config as below in three librenms instances with the same services-wrapper.py version as you mentioned. I’m also in the latest stable version 1.62.2

This is my config:

$config[‘db_host’] = ‘localhost’;
$config[‘db_port’] = ‘3306’;

OK, the only difference I see is that I have
3306 which probably is interpreted as a number and you have
'3306' with apostrophe symbol which probably is read as a string.
The docs show it without apostrophe:

I should have used intval in the code :thinking:

I have created

To be honest i don’t remember if i ever added the apostrophe or if it was there from the initial installation. Config.php configuration utilizes more or less the same “format”. I removed the apostrophe and it works as expected.

Thanks