
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
aws-websocket-api-server
Advanced tools
Testing bootstrap for routing websocket messages to locally running lambdas.
The route configuration file is a dictionary of route actions that maps to Lambda's that will be executed when a message with that route selection property exists.
{
'route selection value': {
id: 'The name of the lamnda in the template.yaml',
debug: true|false,
debugPort: 15988
}
}
The structure of the route-config.json is simple. Just sepcify the Route Key
value that will trigger the lambda as the key in the dictionary. Then supply an object in the form {id: , debug: }.
property | description |
---|---|
id | The id value should be the name of the Lambda as defined in your SAM template. |
debug | The debug flag determines if the lambda waits for your debugger to attach before executing the lambda. |
debugPort | [optional, default: 15988] lets you specify a different debugger port for each lambda so you can debug more than one at a time. |
Install the node module:
yarn add aws-websocket-api-helper -D
Then update your package.json
scripts to include a script to test locally.
"scripts": {
"debug-local": "websocket-api start route-config.json"
}
After installing and adding the script to your package.json
you can simply type:
yarn debug-local
This fires up the websocket server on the default port of 9090 (you can override that with the -p or --port command line argument). Now all you need to do is send your JSON messages to the websocket server as if you app was connecting to the websocket API. You do not need to wrap the json in an event envelope as the websocket server will do this for you.
If your route is configured to connect to a debugger the lambda will start up and wait for your debugger to connect.
Because in your lambda you will be using the APIGW Admin api to talk back to your websocket clients you have no way of doing that right now. It would be great to mock that up locally so we can also respond to the websocket requests.
FAQs
Mock API Gateway for AWS Lambda WebSocket debugging.
The npm package aws-websocket-api-server receives a total of 2 weekly downloads. As such, aws-websocket-api-server popularity was classified as not popular.
We found that aws-websocket-api-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.