{"id":25609542,"url":"https://github.com/immutal0/aws-mqtt-client-module","last_synced_at":"2026-04-19T06:48:01.850Z","repository":{"id":277262069,"uuid":"931239610","full_name":"Immutal0/AWS-MQTT-CLIENT-MODULE","owner":"Immutal0","description":"AWS Websocket pub/sub client javascript module","archived":false,"fork":false,"pushed_at":"2025-02-12T00:22:15.000Z","size":83,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T21:39:48.813Z","etag":null,"topics":["aws","client","javascript","module","pub","sub","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Immutal0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-12T00:11:06.000Z","updated_at":"2025-02-18T01:33:20.000Z","dependencies_parsed_at":"2025-02-13T02:26:38.133Z","dependency_job_id":"160c8ebe-19d3-45e7-861e-70d5d1c93980","html_url":"https://github.com/Immutal0/AWS-MQTT-CLIENT-MODULE","commit_stats":null,"previous_names":["immutal0/aws-mqtt-client-module"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Immutal0%2FAWS-MQTT-CLIENT-MODULE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Immutal0%2FAWS-MQTT-CLIENT-MODULE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Immutal0%2FAWS-MQTT-CLIENT-MODULE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Immutal0%2FAWS-MQTT-CLIENT-MODULE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Immutal0","download_url":"https://codeload.github.com/Immutal0/AWS-MQTT-CLIENT-MODULE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240091006,"owners_count":19746477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","client","javascript","module","pub","sub","websocket"],"created_at":"2025-02-21T21:40:19.783Z","updated_at":"2026-04-19T06:48:01.769Z","avatar_url":"https://github.com/Immutal0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS WebSocket Pub/Sub Client with MQTT.js\n\nThis guide demonstrates how to set up a WebSocket-based Pub/Sub system using AWS IoT and MQTT.js. AWS IoT now supports WebSockets, allowing easy integration for serverless web applications. You can publish messages from AWS Lambda via HTTP POST requests and subscribe to those messages on the client side using WebSockets.\n\n## Prerequisites\n\n1. **AWS IoT Setup**:\n   - Create an IAM role and assign the predefined `AWSIoTDataAccess` policy.\n   - Use [AWS Cognito](https://aws.amazon.com/cognito/) to provide temporary credentials for the front-end application.\n   - Optionally, customize the policy to allow access only to user-specific topics.\n\n2. **Get IoT Endpoint URL**:\n   - Run the following AWS CLI command to get the IoT endpoint URL:\n     ```\n     aws iot describe-endpoint\n     ```\n\n## Installation\n\nTo use the `aws-mqtt-client`, first install it using npm:\n\n```bash\nnpm install aws-mqtt-client --save\n```\n\n## Basic Usage\n\n### Step 1: Set Up AWS IoT MQTT Client\n\nImport the client library and create a new MQTT client instance with your AWS credentials and IoT endpoint.\n\n```js\nimport AWSMqtt from \"aws-mqtt-client\";\n\nconst mqttClient = new AWSMqtt({\n  accessKeyId: AWS_ACCESS_KEY,        // AWS Access Key\n  secretAccessKey: AWS_SECRET_ACCESS_KEY, // AWS Secret Access Key\n  sessionToken: AWS_SESSION_TOKEN,    // Optional: AWS Session Token\n  endpointAddress: AWS_IOT_ENDPOINT_HOST, // IoT Endpoint URL\n  region: \"us-east-1\"                 // AWS Region\n});\n```\n\n### Step 2: Connect and Subscribe to a Topic\n\nUse the `connect` event to establish a connection and the `subscribe` method to listen for messages from a specified topic.\n\n```js\nmqttClient.on(\"connect\", () =\u003e {\n  mqttClient.subscribe(\"test-topic\");\n  console.log(\"Connected to IoT MQTT WebSocket\");\n});\n\nmqttClient.on(\"message\", (topic, message) =\u003e {\n  console.log(message.toString());\n});\n```\n\n### Step 3: Publish a Message\n\nPublish messages to a specific MQTT topic using the `publish` method:\n\n```js\nmqttClient.publish(\"test-topic\", \"Your message here\");\n```\n\n## Summary\n\nThis setup allows you to easily integrate WebSocket-based Pub/Sub messaging into your serverless web application with AWS IoT and MQTT.js. By leveraging AWS's IoT service with WebSockets, you can send real-time messages to the client and publish messages from Lambda functions via HTTP POST requests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimmutal0%2Faws-mqtt-client-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimmutal0%2Faws-mqtt-client-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimmutal0%2Faws-mqtt-client-module/lists"}