Context: Lambda error said 'socket hang up' within nodejs code when performing http/https request to 3rd party backend
Let's describe my tries on solving the problem
- Increase the timeout of lambda -> Not help
- Increase the timeout of httpClient -> Not help
- Figure out that lambda having some problem with connection -> Put HttpAgent to keepalive the connection -> Work perfectly
Code demo:
new JwksClient({
jwksUri: 'xxx' + '/oidc/2/certs',
timeout: 10000,
requestAgent: new Agent({
keepAlive: true
})
})
Top comments (0)