- Newest
- Most votes
- Most comments
Hi,
I believe that you want to use the WebSocket API integration response in API Gateway: see https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-responses.html on how to set it up properly.
Best,
Didier
Based on the available information, it appears that the API Gateway WebSocket API does not currently support specifying a custom close code or reason when closing a WebSocket connection.
The API Gateway Management API's delete-connection command, which is used to disconnect a client from a WebSocket API, does not provide options for specifying a close code or reason. This limitation exists across the various AWS SDKs and the AWS CLI.
While the WebSocket specification and client-side APIs (like the JavaScript WebSocket API) allow for specifying close codes and reasons, this functionality is not currently available in Amazon API Gateway's WebSocket implementation.
For your specific use case with the graphql-ws protocol, which makes use of these status codes, you may need to consider alternative approaches. One possible workaround could be to send a custom message to the client with the desired close code and reason before actually closing the connection. However, this would not be a standard WebSocket close frame with the specified code and reason.
As for future plans, there's no publicly available information indicating whether AWS intends to add this functionality to API Gateway WebSockets. If this feature is important for your use case, you might want to submit a feature request to AWS support or through their feedback channels.
Given the current limitations, you may need to explore alternative solutions or adjust your implementation to work within the constraints of API Gateway's WebSocket capabilities.
Sources
API Gateway Management API examples using AWS CLI - AWS SDK Code Examples
Use @connections commands in your backend service - Amazon API Gateway
Amazon API Gateway Features | API Management | Amazon Web Services
Relevant content
- asked 6 years ago
- asked 5 months ago
- asked 5 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a year ago