cURL Operation timed out oxidized/reload.json

Hello,
after upgrade Freebsd and Librenms to 22.2.0.1 cURL runs into a timeout.
relates to addhost and delhost at the Webpage and CLI.

cURL via CLI is successful (needed 4-6 sec):
/opt/librenms # time curl http://172.30.31.29:9999/oxidized/reload.json
"reloaded list of nodes"0.000u 0.012s 0:04.18 0.2% 404+432k 0+0io 0pf+0w

is it possible to increase the cURL timeout @config?

CLI:
/opt/librenms # ./addhost.php 89.104.14.161
cURL error 28: Operation timed out after 3000 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json

/opt/librenms # ./delhost.php 89.104.14.161
In PendingRequest.php line 691:
cURL error 28: Operation timed out after 3000 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json
In CurlFactory.php line 210:
cURL error 28: Operation timed out after 3000 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json

librenms.log
[previous exception] [object] (GuzzleHttp\Exception\ConnectException(code: 0): cURL error 28: Operation timed out after 3000 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json at /usr/opt/librenms/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210)"}

$ ./validate.php

Component Version
LibreNMS 22.2.0-1-gd8f96a46b
DB Schema 2021_12_02_113537_ports_stp_designated_cost_change_to_int (234)
PHP 7.4.27
Python 3.8.12
MySQL 5.7.33
RRDTool 1.7.2
SNMP 5.9

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

[OK] Composer Version: 2.2.6
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[INFO] Detected Python Wrapper
[OK] Connection to memcached is ok

Problem solved! :slightly_smiling_face:

Change the “timeout(3)” in the BaseApi.php
It’s now ok to create and delete a Device

→ /opt/librenms/app/ApiClients/BaseApi.php

class BaseApi
{
protected $base_uri;

private $client;
protected function getClient(): \Illuminate\Http\Client\PendingRequest
{
    if (is_null($this->client)) {
        $this->client = Http::withOptions([
            'proxy' => Proxy::forGuzzle($this->base_uri),
        ])->baseUrl($this->base_uri)
        ->timeout(3);
    }

    return $this->client;
}

}

  • test with timeout(4);

[2022-02-25T10:05:45.802341+01:00] production.ERROR: cURL error 28: Operation timed out after 4001 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json {“userId”:2,“exception”:"[object] (Illuminate\Http\Client\ConnectionException(code: 0): cURL error 28: Operation timed out after 4001 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json at /usr/opt/librenms/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php:691)
[previous exception] [object] (GuzzleHttp\Exception\ConnectException(code: 0): cURL error 28: Operation timed out after 4001 milliseconds with 0 bytes received (see libcurl - Error Codes) for http://172.30.31.29:9999/oxidized/reload.json at /usr/opt/librenms/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210)"}

  • test with timeout(6);

1 Like

Thank you for sharing this, I was having the exact same issue. Changed the timeout to 10 seconds in /opt/librenms/app/ApiClients/BaseApi.php and it’s working fine now.

2 Likes

thanks! create a PR or create a Setting for this?