I’ve recently been trying out serverless infrastructure for a new project using the Serverless Framework. Unfortunately, I have been completely unable to send any Http Requests from the Lambda.

I have tried the Reactor Netty Client, HttpRequest, and HttpURLConnection. I simply don’t know/understand what the problem is. All code in the function executes without any issue right up until any network related code is run, then, the function simply stalls until its execution time limit runs out.

It begins stalling when java.net.http.HttpClient.newHttpClient() is run, when HttpURLConnection opens a connection, or when reactor.netty.http.client.HttpClient.create() is called. Their are no error or debug messages in CloudWatch, just the function timeout notice. The code all runs perfectly locally/outside of AWS Lambda.

I am using the following Serverless configuration for this function.

   functions:
     <redacted>:
       handler: <redacted>
       environment:
          <redacted>
       snapStart: true
       events:
         - httpApi: 'POST /<redacted>'