newrelic / newrelic-php-agent

The New Relic PHP Agent
https://opensource.newrelic.com/projects/newrelic/newrelic-php-agent
Apache License 2.0
119 stars 62 forks source link

cURL error 6: Could not resolve host: router #255

Open Vugario opened 3 years ago

Vugario commented 3 years ago

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

  1. Docker/kubernetes environment based on php:8.0-fpm-alpine3.13 with the new relic agent version 9.18.1.303 and GuzzleHttp 7.3.0
  2. Make a simple API request with Guzzle
    $client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']);
    $response = $client->request('GET', 'test');
  3. This first number of API calls are executed without a problem. After a while, some API requests are changed to be sent to router instead of to https://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

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

Additional context

javierwilson commented 2 years ago

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

phpfour commented 2 years ago

We are facing this issue in our production environment as well 😓

Guzzle: 7.4.0 NewRelic 9.18.1.303 PHP: 8.0.13

ZNeumann commented 2 years ago

Hello @phpfour and @javierwilson , thanks so much for engaging with this issue. Could you include the PHP version used when encountering this issue?

phpfour commented 2 years ago

@ZNeumann I've added the PHP version, thanks!

benrowe-chuffed commented 2 years ago

I am also experiencing the same issue:

falko100 commented 2 years ago

Same on:

danielsimkus commented 2 years ago

Same here on 7.4.27

ZNeumann commented 2 years ago

Hello all! We just released a new version of the agent (9.19.0) that includes a fix for curl on PHP 8.0. If you could please update your agent and report back whether or not this issue persists? Thanks again for your engagement!

myhreshannon commented 2 years ago

I installed 9.19.0 on a server that hosts our horizon/redis queue and still got this error.

php: 8.0.8, laravel: 8.70.2

phpfour commented 2 years ago

@ZNeumann Thanks for releasing the new agent. However, we are still getting the Could not resolve host: router error.

PHP: 8.1.3
Laravel: 8.83.2
Guzzle: 7.4.1
vismutx commented 2 years ago

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)?

javierwilson commented 2 years ago

@vismutx we followed the advice here https://stackoverflow.com/a/69631399/1170404 and disabled Newrelic support for Guzzle: newrelic.guzzle.enabled = false it worked for us but of course, you miss a lot of useful information that Newrelic can no longer provide.

vismutx commented 2 years ago

@javierwilson Thanks, Better to miss Guzzle information, than all. because for now we turned off php client at all :)

marcvdm commented 2 years ago

Currently running into this issue on production.

php: 8.1.7
Guzzle: 7.4.2
Ak-x commented 1 year ago

Hello, we are now on version 10.5.0; can this be tested against the latest Php Agent version to validate that this issue still exists?