omdbapi / OMDb-API

The Open Movie Database Bug Tracking
422 stars 21 forks source link

Getting ECONNRESET on calling api from AWS Lambda #150

Open shadabk96 opened 5 years ago

shadabk96 commented 5 years ago

I'm trying to hit omdb api via an AWS Lambda function but it is throwing the following error. I'm using Node v12.10 and calling via https module. Another point to be noted is that the call is working perfectly from my local machine.

Full stack trace:

Got an error: Error: Client network socket disconnected before secure TLS connection was established
at connResetException (internal/errors.js:559:14)
at TLSSocket.onConnectEnd (_tls_wrap.js:1357:19)
at Object.onceWrapper (events.js:297:20)
at TLSSocket.emit (events.js:214:15)
at endReadableNT (_stream_readable.js:1178:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
code: 'ECONNRESET',
path: null,
host: 'www.omdbapi.com',
port: 443,
localAddress: undefined
} 
omdbapi commented 5 years ago

Found this reply from Amazon support:

If you're using NodeJS, make sure that you have completed all asynchronous processing prior to returning from your request handler; otherwise, you may have a socket connection that is frozen (and subsequently thawed) across requests, which will often lead to a connection reset. Async processing in NodeJS is a frequent source of this type of error.

jneves commented 5 years ago

Are you using that lambda on a VPC and if yes, have you set up a NAT gateway so the lambda can talk to the Internet?

hoIIer commented 4 years ago

@shadabk96 were you able to make any progress? I'm getting a similar problem in a lambda@edge function...