websocket close connection with error code
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
in `WebsocketAPI` can we have a method that closes a websocket connection with a specified code?
[similar to this](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)
according to the websocket protocol we should be able to do this -> [spec](https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4)
right now, in API gateway logs, the connection is always closed with status code 1000 when calling the existing `close` method:
```python3
app.websocket_api.close(event.connection_id)
```
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,
...
```
Contributor guide
Research direction
Start at the WebsocketAPI entry point and inspect the existing close(event.connection_id) call described in the issue. Compare its behavior with the linked WebSocket close documentation and API Gateway logs; done means callers can provide a close code and API Gateway reports that code instead of always reporting 1000.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- api, cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100