-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket.setKeepAlive is not called, which could prevent timeouts during long requests #4439
Labels
Comments
kuhe
added
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Jun 6, 2023
RanVaknin
added
p2
This is a standard priority issue
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Jun 6, 2023
A possible workaround would be: import https from "https";
const keepAliveMsecs = 5 * 1000;
const tempHttpsRequestFn = https.request;
https.request = (options, callback) => {
const clientRequest = tempHttpsRequestFn(options, callback);
clientRequest.once('socket', (socket) => {
console.log(keepAliveMsecs)
socket.setKeepAlive(true, keepAliveMsecs || 0);
});
return clientRequest;
}; A quick example would be: import AWS from "aws-sdk";
import https from "https";
const keepAliveMsecs = 5 * 1000;
const tempHttpsRequestFn = https.request;
https.request = (options, callback) => {
const clientRequest = tempHttpsRequestFn(options, callback);
clientRequest.once('socket', (socket) => {
socket.setKeepAlive(true, keepAliveMsecs || 0);
});
return clientRequest;
};
const client = new AWS.Lambda({
region: 'us-east-2'
});
const response = await client.invoke({
FunctionName: "sleep",
Payload: JSON.stringify({
sleep: 100
})
}).promise();
console.log(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
When making very long duration requests, such as a lambda invoke that takes over 5 minutes to complete, the SDK may eventually timeout even if the response completes because the socket is not kept alive.
A current workaround seems to have fixed this issue for an internal customer, so we should add a
socket.setKeepAlive
call to the Node.js HTTP request.Expected Behavior
long request >5 min completes
Current Behavior
long request >5 min reports a timeout even if the server completes the request successfully
Reproduction Steps
invoke a lambda transaction that takes a long time, 5-15 minutes.
Possible Solution
add
socket.setKeepAlive(true, xxx)
somewhere in the request creation processAdditional Information/Context
No response
SDK version used
current
Environment details (OS name and version, etc.)
EC2 to Lambda
The text was updated successfully, but these errors were encountered: