newrelic-php-agent: cURL error 6: Could not resolve host: router
Description
When using the agent version 9.18.1.303 in combination with guzzlehttp 7.3.0 our requests are sometimes changed to have the host “router”. We make a simple API call to any url, and it ends up performing a curl request to router which in turn throws an exception:
cURL error 6: Could not resolve host: router
We noticed this problem in our production environment where we perform many API calls. Most of them succeeded but after a while, some are failing with this described issue. When this error occurs, some API calls still succeed so the error is only happening for a small subset of requests, making this issue very difficult to find and debug.
It took us many days to realize this was the cause, but when reverting NewRelic back to its previous release this issue was resolved.
Steps to Reproduce
- Docker/kubernetes environment based on
php:8.0-fpm-alpine3.13with the new relic agent version9.18.1.303and GuzzleHttp 7.3.0 - Make a simple API request with Guzzle
$client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']);
$response = $client->request('GET', 'test');
- This first number of API calls are executed without a problem. After a while, some API requests are changed to be sent to
routerinstead of tohttps://foo.com/api/test
Expected Behavior
The request should be sent to https://foo.com/api/test instead of to router which fails the request
NOTE: # ( Tell us what you expected to happen. )
Relevant Logs / Console output
This is our stacktrace, which is no different for the failed requests as for the successful ones (except for the exception handling at the end of course).
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210 GuzzleHttp\Handler\CurlFactory::createRejection
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:158 GuzzleHttp\Handler\CurlFactory::finishError
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:110 GuzzleHttp\Handler\CurlFactory::finish
vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php:47 GuzzleHttp\Handler\CurlHandler::__invoke
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php:28 GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php:48 GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}
vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php:35 GuzzleHttp\PrepareBodyMiddleware::__invoke
vendor/guzzlehttp/guzzle/src/Middleware.php:31 GuzzleHttp\Middleware::GuzzleHttp\{closure}
vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php:71 GuzzleHttp\RedirectMiddleware::__invoke
vendor/guzzlehttp/guzzle/src/Middleware.php:63 GuzzleHttp\Middleware::GuzzleHttp\{closure}
vendor/guzzlehttp/guzzle/src/HandlerStack.php:75 GuzzleHttp\HandlerStack::__invoke
vendor/guzzlehttp/guzzle/src/Client.php:331 GuzzleHttp\Client::transfer
vendor/guzzlehttp/guzzle/src/Client.php:168 GuzzleHttp\Client::requestAsync
vendor/guzzlehttp/guzzle/src/Client.php:187 GuzzleHttp\Client::request
vendor/guzzlehttp/guzzle/src/Client.php:92 GuzzleHttp\Client::__call
Your Environment
We run on GKE with a Docker file based on php:8.0-fpm-alpine3.13.
GuzzleHttp version 7.3.0
NewRelic agent 9.18.1.303
TIP: # ( Include as many relevant details about your environment as possible. )
- ex: Browser name and version:
- ex: Operating System and version:
Additional context
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 6
- Comments: 15 (2 by maintainers)
@vismutx we followed the advice here https://stackoverflow.com/a/69631399/1170404 and disabled Newrelic support for Guzzle:
newrelic.guzzle.enabled = falseit worked for us but of course, you miss a lot of useful information that Newrelic can no longer provide.Any ideas what is the reason? May be we can change something to get around this bug?
https://github.com/newrelic/newrelic-php-agent/releases/tag/v9.18.1.303 May be this is because of route caching? Can somebody test with it (i have only production with new-relic)?
@ZNeumann Thanks for releasing the new agent. However, we are still getting the
Could not resolve host: routererror.I can confirm this. The issue for us appears even before doing the request just with:
$client = new GuzzleHttp\Client();Guzzle 6.5 NewRelic 9.18.1.303