Skip to content
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

close websocket connection with error code #3789

Closed
2 tasks
naomiven opened this issue Jul 21, 2023 · 5 comments
Closed
2 tasks

close websocket connection with error code #3789

naomiven opened this issue Jul 21, 2023 · 5 comments
Assignees
Labels
closed-for-staleness feature-request This issue requests a feature. service-api This issue is caused by the service API, not the SDK implementation.

Comments

@naomiven
Copy link

Describe the feature

in ApiGatewayManagementApi client can we have a method that closes a websocket connection with a specified code?

similar to this

according to the websocket protocol we should be able to do this -> spec

looks like there is no way to do this currently -> https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigatewaymanagementapi/client/close.html
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewaymanagementapi/delete-connection.html

right now, in API gateway, the connection is always closed with status code 1000 when I close the connection through AWS chalice (which calls boto3 client)

API gateway logs:

Endpoint request body after transformations: 
...
        {
          "routeKey": "$disconnect",
          "disconnectStatusCode": 1000,
          "authorizer": {
              "principalId": "user"
        },
        "eventType": "DISCONNECT",
        "requestTime": "20/Jul/2023:23:29:25 +0000",
        "messageDirection": "IN",
        "disconnectReason": "Connection Closed Normally",
        "connectedAt": 1689895754759,
        "requestTimeEpoch": 1689895765983,
...

Use Case

this will be good for error handling in websocket messages. when an error occurs, we should be able to close a connection and specify the error code, as per the websocket protocol spec.

Proposed Solution

add an argument for code and reason in the close and delete-connection commands

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

1.28.5

Environment details (OS name and version, etc.)

MacOS Monterey 12.5.1

@naomiven naomiven added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2023
@tim-finnigan tim-finnigan self-assigned this Jul 24, 2023
@tim-finnigan
Copy link
Contributor

Hi @naomiven thanks for reaching out. I think this request would needed to get routed to the API Gateway Management team, as they own the underlying APIs. (We recommend reaching out through AWS Support if you have a support plan, otherwise we can reach out on your behalf.)

As an alternative approach have you looked into using the post_to_connection command? I saw you also created an issue in the Chalice repository for this (aws/chalice#2060) which may be the better place to track this going forward.

@tim-finnigan tim-finnigan added response-requested Waiting on additional information or feedback. service-api This issue is caused by the service API, not the SDK implementation. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 24, 2023
@github-actions
Copy link

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 30, 2023
@naomiven
Copy link
Author

@tim-finnigan Thank you for your suggestions. I just contacted AWS support and will let you know if they will accept the feature request.

As an alternative approach have you looked into using the post_to_connection command?

yes right now i am using post_to_connection as a workaround, however this does not close the connection. I am merely sending a string with the expected error code.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional information or feedback. labels Aug 1, 2023
@tim-finnigan
Copy link
Contributor

Ok thanks for following up. Since the feature request would need to get implemented by either the API Gateway team and/or the Chalice team, I think we can close this and use the Support ticket/Chalice issue to track the request going forward. But please let us know if you have updates to share that could help others with your same use case.

@tim-finnigan tim-finnigan added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Aug 1, 2023
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 4, 2023
@github-actions github-actions bot closed this as completed Aug 4, 2023
@boblund
Copy link

boblund commented Sep 30, 2024

Is there any action on this issue? Since browsers do not make HTTP status codes generated in the AWS $connect lambda available to websocket clients, it is really essential for a AWS $connect lambda to be able to close the websocket and supply a websocket status code in the 4000 - 4009 range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request This issue requests a feature. service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

3 participants