aws-samples / simple-websockets-chat-app

This SAM application provides the Lambda functions, DynamoDB table, and roles to allow you to build a simple chat application based on API Gateway's new WebSocket-based API feature.
MIT No Attribution
682 stars 280 forks source link

Close specific WebSocket API Gateway connection. #10

Closed JoseRolles closed 5 years ago

JoseRolles commented 5 years ago

How do we close a specific WebSocket API Gateway client connection from the server side?

JoseRolles commented 5 years ago

Documentation at the following link says it is possible to close a connection from the backend by using @connections endpoint. It points to another documentation page which mentions nothing about closing a connection from the backend: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-route-keys-connect-disconnect.html

Also, I checked the JavaScript SDK reference and the only method is postToConnection without any mention of disconnecting the connectionId. https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ApiGatewayManagementApi.html

dgomesbr commented 5 years ago

@JoseRolles using @connections, DELETE to it should disconnect the client.

knopp commented 5 years ago

Perhaps the documentation could be updated so that people don't need to search github issues for answers?

kkirov commented 1 year ago

Use DeleteConnectionCommand - https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-apigatewaymanagementapi/classes/deleteconnectioncommand.html