-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
When I try to post to a WebsocketMessage to my connections neither the postToConnection functions rejects an error nor it does resolves within the given requestTimeout. In the end I run into lambda timeout.
In some cases I have got lambda timeout for my lambda function which distributes messages to websocket connection. While debugging I added logging and found that in the cases the lambda times out the "Start sending connection.id" log is written but "Finished sending connection.id" log gets not written and for the same connection.id also the error log is not written. Therefore I assume the postToConnection function does not resolve or rejects even after the requestTimeout of 5sec is reached. The Lambda functions Timeout is set to 30sec.
async sendMessage(connection: WebsocketConnection, message: WebsocketMessage) {
const data = new TextEncoder().encode(JSON.stringify(message));
const postParams: PostToConnectionCommandInput = {
ConnectionId: connection.id,
Data: data,
};
try {
logger.debug(`Start sending ${connection.id}`);
await this.client.postToConnection(postParams, { requestTimeout: 5000 });
logger.debug(`Finished sending ${connection.id}`);
} catch (err) {
logger.error(`Could not send to connectionId ${connection.id}`, err);
await this.removeConnection(connection.id);
}
}
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node.js 20.x
Reproduction Steps
I do not not know why it appears, that the postToConnection function does not resolves or rejects.
Observed Behavior
Sometimes but not every time the postToConnection function does not resolve or reject.
Expected Behavior
I would expect postToConnection to reslove or reject at least after the requestTimeout is reached.
Possible Solution
No response
Additional Information/Context
No response