Score:0

Guzzle's POST request timing out from server (locally works)

cn flag

I'm trying to POST request my API, which is in a nginx server, from an apache server, but no response is obtained. Requests from localhost to the same nginx server work fine. But, when the same snippet is executed in the production server, we get a time out, and Guzzle throws an exception after few seconds.

Exception threw:

<br />
<b>Fatal error</b>:  Uncaught GuzzleHttp\Exception\ConnectException: cURL error 7: Failed connect to 192.140.88.50:80; Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for 192.140.88.50/infotech/selecionar_cidades in /var/www/html/abmcash.com.br/web/abmNew2/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210
Stack trace:
#0 /var/www/html/abmcash.com.br/web/abmNew2/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(158): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /var/www/html/abmcash.com.br/web/abmNew2/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(110): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /var/www/html/abmcash.com.br/web/abmNew2/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(47): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Objec in <b>/var/www/html/abmcash.com.br/web/abmNew2/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php</b> on line <b>210</b><br />

Ping and Traceroute commands were executed and both of them succeded.

None of the machines have any firewall rule preventing any kind of communication between them.

This is the snippet that sends the request:

$base_url = "127.0.0.1:8000";
$url = $base_url . $rota;
$client = new Client([
    'headers' => ['Content-Type' => 'application/json;charset=utf-8']
]);

$payload =  json_encode($data);

$response = $client->post($url, ['body' => $payload]);

Apache is listening the port 80 and Nginx is listening the port 8000, and both of them are up and running

PHP version: 7.4.20

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.