Connection ID Not getting deleted in dynamo Db table when using websocket API.

0

I have a created a websocket api and the routes to connect and disconnect is set to lambda functions which put connection id to a dynamo db table and delete it respectively. But when the client connection to the websocket is terminated unexpectedly ( device shutdown, wifi/data turn off etc) the client id is not deleted automatically. What can i do to avoid this and make sure if a client is disconnected in any way i have the connection id deleted? Please provide code layout if applicable.

1개 답변
0

Hello Phoenix2819,

I think you are missing step 8 and 9 described in the AWS blog here - Managing sessions of anonymous users in WebSocket API-based applications

The sample code is provided in the blog link above which uses EventBridge to schedule OnDelete function execution every 5 minutes.

Step 8 - If the connection breaks, the WebSocket API calls the OnDisconnect Lambda function automatically. The function marks the connection ID for the given user ID as inactive.

Step 9 - If the user does not return within 5 minutes, Amazon EventBridge scheduler invokes the OnDelete Lambda function, which deletes items with more than 5 minutes of inactivity from Connections and Sessions tables.

AWS
답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠