You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ack-connect-route/README.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
-
## Websocket API Gateway acknowledgement for $connect route.
2
1
3
-
The Serverless Application Model (SAM) template deploys an Amazon WebSocket API Gateway and two AWS Lambda functions. When a client connects, the API Gateway creates a $connect route with Lambda proxy integration. The first Lambda function processes the initial connection, capturing both the Connection ID and API Gateway stage URL, then asynchronously triggers the second Lambda function. This second function validates the Connection ID and, if valid, uses SDK API calls to send a greeting message back to the client.
2
+
## Websocket acknowledgement for $connect route in Amazon API Gateway
3
+
4
+
The Serverless Application Model (SAM) template deploys an Amazon WebSocket API Gateway and two AWS Lambda functions. When a client connects, the API Gateway creates a $connect route with Lambda proxy integration. The first Lambda function processes the initial connection, capturing both the Connection ID and API Gateway stage URL, then asynchronously invokes the second Lambda function. This second function validates the Connection ID and, if valid, uses SDK API calls to send a greeting message back to the client.
4
5
5
6
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns
6
7
@@ -34,13 +35,13 @@ Important: this application uses various AWS services and there are costs associ
34
35
* Enter the desired AWS Region
35
36
* Allow SAM CLI to create IAM roles with the required permissions.
36
37
37
-
Once you have run guided mode once, you can use `sam deploy` in future to use these defaults.
38
+
After running guided mode once, you can use `sam deploy` in future to use these defaults.
38
39
39
40
1. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.
40
41
41
42
## Testing
42
43
43
-
Once the application is deployed, retrieve the WebSocketURL value from CloudFormation Outputs. To test the WebSocket API, you can use [wscat](https://github.com/websockets/wscat) which is an open-source command line tool.
44
+
After deployment, retrieve the `WebSocketURL` value from CloudFormation Outputs. To test the WebSocket API, you can use [wscat](https://github.com/websockets/wscat) which is an open-source command line tool.
44
45
45
46
1. [Install NPM](https://www.npmjs.com/get-npm).
46
47
@@ -53,7 +54,7 @@ Once the application is deployed, retrieve the WebSocketURL value from CloudForm
53
54
$ wscat -c <YOUR WEBSOCKET URL>
54
55
```
55
56
56
-
4. To test the custom route and its associated function, send a JSON-formatted request. The Lambda function sends back the value of the "data" key using the callback URL:
57
+
4. To test the custom route and its associated function, send a JSON-formatted request for example {"Test":"input"}. The Lambda function sends back the value of the "data" key using the callback URL:
57
58
```
58
59
$ wscat -c <YOURWEBSOCKETURL>
59
60
connected (press CTRL+C to quit)
@@ -62,12 +63,8 @@ connected (press CTRL+C to quit)
0 commit comments