2

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

2
  • Could you add more information regarding the functions themselves and have a look at the following - stackoverflow.com/questions/53898894/… Commented Dec 16, 2019 at 10:42
  • I researched some information and found that Lambda can't connect to anything outside of the VPC. I think this is problem with api gateway. I found tab where I can create VCP links which Provide access to HTTP(S) resources within your Amazon Virtual Private Cloud (VPC). But for now it doesn't work:) Commented Dec 16, 2019 at 14:04

1 Answer 1

1

The problem was in VPC.

Since the lambda function was in the VPC, it could not access external resources.

The simplest solution is to create a lambda funtion without the VPC.

The full answer can be found at this URL:

AWS lambda invoke not calling another lambda function - Node.js

The anwer of johni

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.