From 518382036bd27e8bc7e2f147fdd99546d4198fc6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 25 Aug 2024 18:35:24 +0000 Subject: [PATCH] Exception handling added at many places --- src/Core/Search.php | 7 ++- src/Model/Photo.php | 14 +++++- src/Model/Post/Media.php | 25 ++++++----- src/Model/User.php | 18 +++++--- src/Module/Contact/MatchInterests.php | 14 +++++- src/Network/Probe.php | 63 +++++++++++++++++++++++---- src/Protocol/ActivityPub/Delivery.php | 14 ++++-- src/Protocol/DFRN.php | 7 ++- src/Protocol/Diaspora.php | 7 ++- src/Security/ExAuth.php | 6 ++- src/Util/HTTPSignature.php | 7 ++- src/Util/Network.php | 1 + src/Util/ParseUrl.php | 7 ++- src/Worker/CheckRelMeProfileLink.php | 7 ++- src/Worker/OnePoll.php | 14 +++++- src/Worker/UpdateServerPeers.php | 7 ++- 16 files changed, 174 insertions(+), 44 deletions(-) diff --git a/src/Core/Search.php b/src/Core/Search.php index e9ec395ab3..776a0a0e50 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -220,7 +220,12 @@ class Search $return = Contact::searchByName($search, $mode, true); } else { $p = $page > 1 ? 'p=' . $page : ''; - $curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]); + try { + $curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } if ($curlResult->isSuccess()) { $searchResult = json_decode($curlResult->getBodyString(), true); if (!empty($searchResult['profiles'])) { diff --git a/src/Model/Photo.php b/src/Model/Photo.php index d2dd36975a..e2d38241d8 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -588,7 +588,12 @@ class Photo $filename = basename($image_url); if (!empty($image_url)) { - $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]); + try { + $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return false; + } Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]); $img_str = $ret->getBodyString(); $type = $ret->getContentType(); @@ -1043,7 +1048,12 @@ class Photo { $filename = basename($image_url); if (!empty($image_url)) { - $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]); + try { + $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]); $img_str = $ret->getBodyString(); $type = $ret->getContentType(); diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index 033ae0fbc8..b62771274e 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -185,18 +185,21 @@ class Media // Workaround for systems that can't handle a HEAD request if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) { - $curlResult = DI::httpClient()->get($media['url'], HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => $timeout]); - } - - if ($curlResult->isSuccess()) { - if (empty($media['mimetype'])) { - $media['mimetype'] = $curlResult->getContentType() ?? ''; + try { + $curlResult = DI::httpClient()->get($media['url'], HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => $timeout]); + if ($curlResult->isSuccess()) { + if (empty($media['mimetype'])) { + $media['mimetype'] = $curlResult->getContentType() ?? ''; + } + if (empty($media['size'])) { + $media['size'] = (int)($curlResult->getHeader('Content-Length')[0] ?? 0); + } + } else { + Logger::notice('Could not fetch head', ['media' => $media]); + } + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); } - if (empty($media['size'])) { - $media['size'] = (int)($curlResult->getHeader('Content-Length')[0] ?? 0); - } - } else { - Logger::notice('Could not fetch head', ['media' => $media]); } } diff --git a/src/Model/User.php b/src/Model/User.php index 87caab1b6a..2a68e8f899 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1411,12 +1411,18 @@ class User $photo_failure = false; $filename = basename($photo); - $curlResult = DI::httpClient()->get($photo, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]); - if ($curlResult->isSuccess()) { - Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]); - $img_str = $curlResult->getBodyString(); - $type = $curlResult->getContentType(); - } else { + try { + $curlResult = DI::httpClient()->get($photo, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]); + if ($curlResult->isSuccess()) { + Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]); + $img_str = $curlResult->getBodyString(); + $type = $curlResult->getContentType(); + } else { + $img_str = ''; + $type = ''; + } + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); $img_str = ''; $type = ''; } diff --git a/src/Module/Contact/MatchInterests.php b/src/Module/Contact/MatchInterests.php index 8ebfe2a49f..69713ef746 100644 --- a/src/Module/Contact/MatchInterests.php +++ b/src/Module/Contact/MatchInterests.php @@ -109,10 +109,20 @@ class MatchInterests extends BaseModule continue; } - $result = $this->httpClient->post($server . '/search/user/tags', $searchParameters, [], 0, HttpClientRequest::CONTACTDISCOVER); + try { + $result = $this->httpClient->post($server . '/search/user/tags', $searchParameters, [], 0, HttpClientRequest::CONTACTDISCOVER); + } catch (\Throwable $th) { + $this->logger->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + continue; + } if (!$result->isSuccess()) { // try legacy endpoint - $result = $this->httpClient->post($server . '/msearch', $searchParameters, [], 0, HttpClientRequest::CONTACTDISCOVER); + try { + $result = $this->httpClient->post($server . '/msearch', $searchParameters, [], 0, HttpClientRequest::CONTACTDISCOVER); + } catch (\Throwable $th) { + $this->logger->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + continue; + } if (!$result->isSuccess()) { $this->logger->notice('Search-Endpoint not available for server.', ['server' => $server]); continue; diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 1fa9412d9c..e290553a70 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -214,7 +214,12 @@ class Probe Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url]); $xrd = null; - $curlResult = DI::httpClient()->get($ssl_url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($ssl_url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } $ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0); if ($curlResult->isSuccess()) { $xml = $curlResult->getBodyString(); @@ -231,7 +236,12 @@ class Probe } if ($ssl_connection_error && !is_object($xrd) && !empty($url)) { - $curlResult = DI::httpClient()->get($url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } $connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0); if ($curlResult->isTimeout()) { Logger::info('Probing timeout', ['url' => $url]); @@ -447,7 +457,12 @@ class Probe */ private static function getHideStatus(string $url): bool { - $curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return false; + } if (!$curlResult->isSuccess()) { return false; } @@ -886,7 +901,12 @@ class Probe private static function pollZot(string $url, array $data): array { - $curlResult = DI::httpClient()->get($url, 'application/x-zot+json', [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($url, 'application/x-zot+json', [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return $data; + } if ($curlResult->isTimeout()) { return $data; } @@ -1067,7 +1087,12 @@ class Probe */ private static function pollNoscrape(string $noscrape_url, array $data): array { - $curlResult = DI::httpClient()->get($noscrape_url, HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($noscrape_url, HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return $data; + } if ($curlResult->isTimeout()) { self::$isTimeout = true; return $data; @@ -1227,7 +1252,12 @@ class Probe */ private static function pollHcard(string $hcard_url, array $data): array { - $curlResult = DI::httpClient()->get($hcard_url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($hcard_url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } if ($curlResult->isTimeout()) { self::$isTimeout = true; return []; @@ -1517,7 +1547,12 @@ class Probe } // Fetch all additional data from the feed - $curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } if ($curlResult->isTimeout()) { self::$isTimeout = true; return []; @@ -1904,7 +1939,12 @@ class Probe return ''; } - $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return ''; + } if ($curlResult->isSuccess() && !empty($curlResult->getBodyString())) { $noscrape = json_decode($curlResult->getBodyString(), true); @@ -1980,7 +2020,12 @@ class Probe private static function updateFromFeed(array $data): string { // Search for the newest entry in the feed - $curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::ATOM_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + try { + $curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::ATOM_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return ''; + } if (!$curlResult->isSuccess() || !$curlResult->getBodyString()) { return ''; } diff --git a/src/Protocol/ActivityPub/Delivery.php b/src/Protocol/ActivityPub/Delivery.php index f12e838ca1..7a7d484b8d 100644 --- a/src/Protocol/ActivityPub/Delivery.php +++ b/src/Protocol/ActivityPub/Delivery.php @@ -115,10 +115,16 @@ class Delivery $data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id); if (!empty($data)) { $timestamp = microtime(true); - $response = HTTPSignature::post($data, $inbox, $owner); - $runtime = microtime(true) - $timestamp; - $success = $response->isSuccess(); - $serverfail = $response->isTimeout(); + try { + $response = HTTPSignature::post($data, $inbox, $owner); + $success = $response->isSuccess(); + $serverfail = $response->isTimeout(); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + $success = false; + $serverfail = true; + } + $runtime = microtime(true) - $timestamp; if (!$success) { // 5xx errors are problems on the server. We don't need to continue delivery then. if (!$serverfail && ($response->getReturnCode() >= 500) && ($response->getReturnCode() <= 599)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 4d24a76282..1cd5a39511 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -996,7 +996,12 @@ class DFRN $content_type = ($public_batch ? 'application/magic-envelope+xml' : 'application/json'); - $postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DFRN); + try { + $postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DFRN); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return -25; + } Item::incrementOutbound(Protocol::DFRN); $xml = $postResult->getBodyString(); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index b706a40075..f449ed0187 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -2955,7 +2955,12 @@ class Diaspora if (!intval(DI::config()->get('system', 'diaspora_test'))) { $content_type = (($public_batch) ? 'application/magic-envelope+xml' : 'application/json'); - $postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DIASPORA); + try { + $postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DIASPORA); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return 0; + } $return_code = $postResult->getReturnCode(); Item::incrementOutbound(Protocol::DIASPORA); } else { diff --git a/src/Security/ExAuth.php b/src/Security/ExAuth.php index 5c22979841..43aff95487 100644 --- a/src/Security/ExAuth.php +++ b/src/Security/ExAuth.php @@ -230,7 +230,11 @@ class ExAuth $url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user; - $curlResult = DI::httpClient()->get($url, HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTVERIFIER]); + try { + $curlResult = DI::httpClient()->get($url, HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTVERIFIER]); + } catch (\Throwable $th) { + return false; + } if (!$curlResult->isSuccess()) { return false; diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 8b03a1211a..d7679abd1f 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -366,7 +366,12 @@ class HTTPSignature return true; } - $postResult = self::post($data, $target, $owner); + try { + $postResult = self::post($data, $target, $owner); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return false; + } $return_code = $postResult->getReturnCode(); return ($return_code >= 200) && ($return_code <= 299); diff --git a/src/Util/Network.php b/src/Util/Network.php index a428f0440c..a7e2fa536a 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -79,6 +79,7 @@ class Network try { $curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, $options); } catch (\Exception $e) { + Logger::notice('Got exception', ['code' => $e->getCode(), 'message' => $e->getMessage()]); return false; } } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 83fa1fe912..5196740361 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -65,7 +65,12 @@ class ParseUrl // Workaround for systems that can't handle a HEAD request. Don't retry on timeouts. if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() >= 400) && !in_array($curlResult->getReturnCode(), [408, 504])) { - $curlResult = DI::httpClient()->get($url, $accept, array_merge([HttpClientOptions::CONTENT_LENGTH => 1000000], $options)); + try { + $curlResult = DI::httpClient()->get($url, $accept, array_merge([HttpClientOptions::CONTENT_LENGTH => 1000000], $options)); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return []; + } } if (!$curlResult->isSuccess()) { diff --git a/src/Worker/CheckRelMeProfileLink.php b/src/Worker/CheckRelMeProfileLink.php index dde18bea37..0aeaf49c2c 100644 --- a/src/Worker/CheckRelMeProfileLink.php +++ b/src/Worker/CheckRelMeProfileLink.php @@ -51,7 +51,12 @@ class CheckRelMeProfileLink } $xrd_timeout = DI::config()->get('system', 'xrd_timeout'); - $curlResult = DI::httpClient()->get($owner['homepage'], HttpClientAccept::HTML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTVERIFIER]); + try { + $curlResult = DI::httpClient()->get($owner['homepage'], HttpClientAccept::HTML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTVERIFIER]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return; + } if (!$curlResult->isSuccess()) { Logger::notice('Could not cURL the homepage URL', ['owner homepage' => $owner['homepage']]); return; diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 2686f00f7c..a305f85d5e 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -152,7 +152,12 @@ class OnePoll $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-'); Item::incrementInbound(Protocol::FEED); - $curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar, HttpClientOptions::REQUEST => HttpClientRequest::FEEDFETCHER]); + try { + $curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar, HttpClientOptions::REQUEST => HttpClientRequest::FEEDFETCHER]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return false; + } unlink($cookiejar); Logger::debug('Polled feed', ['url' => $contact['poll'], 'http-code' => $curlResult->getReturnCode(), 'redirect-url' => $curlResult->getRedirectUrl()]); @@ -492,7 +497,12 @@ class OnePoll Contact::update(['hub-verify' => $verify_token], ['id' => $contact['id']]); } - $postResult = DI::httpClient()->post($url, $params, [], 0, HttpClientRequest::PUBSUB); + try { + $postResult = DI::httpClient()->post($url, $params, [], 0, HttpClientRequest::PUBSUB); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return false; + } Logger::info('Hub subscription done', ['result' => $postResult->getReturnCode()]); diff --git a/src/Worker/UpdateServerPeers.php b/src/Worker/UpdateServerPeers.php index 3df71d42fc..9c5cce731b 100644 --- a/src/Worker/UpdateServerPeers.php +++ b/src/Worker/UpdateServerPeers.php @@ -32,7 +32,12 @@ class UpdateServerPeers return; } - $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERDISCOVER]); + try { + $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERDISCOVER]); + } catch (\Throwable $th) { + Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]); + return; + } if (!$ret->isSuccess() || empty($ret->getBodyString())) { Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]); return;