I want to execute curl query from one lambda function to another. But I have error in postman:
{"message": "Endpoint request timed out"}
I tried to handle this error. I got this error message:
2019-12-16T09:59:27.830Z 4189c32a-1e9c-4898-a59e-6149c49eaab2 Task timed out after 30.03 seconds
PHP-FPM seems to be running already, this might be because Lambda stopped the bootstrap process but didn't leave us an opportunity to stop PHP-FPM. Stopping PHP-FPM now to restart from a blank slate. Fatal error: Uncaught Bref\Runtime\FastCgi\FastCgiCommunicationFailed: Error communicating with PHP-FPM to read the HTTP response. A root cause of this can be that the Lambda (or PHP) timed out, for example when trying to connect to a remote API or database, if this happens continuously check for those! Original exception message: hollodotme\FastCGI\Exceptions\TimedoutException Read timed out in /var/task/vendor/bref/bref/src/Runtime/PhpFpm.php:126 Stack trace:
0 /opt/bootstrap(30): Bref\Runtime\PhpFpm->proxy(Array)
1 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(92): {closure}(Array, Object(Bref\Context\Context))
2 /opt/bootstrap(34): Bref\Runtime\LambdaRuntime->processNextEvent(Object(Closure))
This is my code:
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 500, // timeout on connect
CURLOPT_TIMEOUT => 500, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_USERAGENT => "",
CURLOPT_COOKIESESSION => false,
// CURLOPT_COOKIEJAR => $this->ckfile, // Cookies
// CURLOPT_COOKIEFILE => $this->ckfile, //Cookies...yum
);
//Go go go!
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$output['content'] = curl_exec( $ch );
$output['err'] = curl_errno( $ch );
$output['errmsg'] = curl_error( $ch );
$output['header'] = curl_getinfo( $ch );
dd($output);
When I use guzzlehttp:
$client = new \GuzzleHttp\Client();
$request = $client->get($url);
$response = $request->getBody();
I get only:
Task timed out after 30.03 seconds