{"id":20611915,"url":"https://github.com/jimmyn/aws-mqtt-client","last_synced_at":"2025-04-06T22:06:43.419Z","repository":{"id":9710747,"uuid":"63072044","full_name":"jimmyn/aws-mqtt-client","owner":"jimmyn","description":"AWS Websocket Pub/Sub client","archived":false,"fork":false,"pushed_at":"2023-03-04T07:02:43.000Z","size":271,"stargazers_count":155,"open_issues_count":6,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T21:09:41.212Z","etag":null,"topics":["aws","aws-iot","aws-mqtt","aws-websockets","mqtt","websockets"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimmyn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-07-11T13:53:23.000Z","updated_at":"2024-10-02T05:55:19.000Z","dependencies_parsed_at":"2024-06-18T18:59:10.692Z","dependency_job_id":"754a368b-4e9f-4dd7-ace3-cdcd525a7842","html_url":"https://github.com/jimmyn/aws-mqtt-client","commit_stats":{"total_commits":22,"total_committers":4,"mean_commits":5.5,"dds":0.5454545454545454,"last_synced_commit":"21664b18acf224c6ab9fe400fd8d59597f82eedd"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmyn%2Faws-mqtt-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmyn%2Faws-mqtt-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmyn%2Faws-mqtt-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmyn%2Faws-mqtt-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimmyn","download_url":"https://codeload.github.com/jimmyn/aws-mqtt-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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","aws-iot","aws-mqtt","aws-websockets","mqtt","websockets"],"created_at":"2024-11-16T10:22:35.906Z","updated_at":"2025-04-06T22:06:43.393Z","avatar_url":"https://github.com/jimmyn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Websocket Pub/Sub client\n\n[AWS MQTT](http://docs.aws.amazon.com/iot/latest/developerguide/protocols.html) Websocket Pub/Sub with AWS IoT based on [MQTT.js](https://github.com/mqttjs/MQTT.js).\nRecently [AWS released support of WebSockets for IoT](https://aws.amazon.com/about-aws/whats-new/2016/01/aws-iot-now-supports-websockets-custom-keepalive-intervals-and-enhanced-console/) service. It is very easy to use as Pub/Sub message system for serverless web applications. You can post new messages from `AWS lambda function` via `http post request` and receive them as websocket messages on client.\n\n## Installing it\n\n````bash\nnpm i aws-mqtt-client --save\n````\n\n## Basic usage\n\n1.  Create an IAM role and asign predefined `AWSIoTDataAccess` policy. (It is better to use [AWS Cognito](https://aws.amazon.com/cognito/) to provide temporary credentials for the front-end application, you can also customize policy to allow access only to user specific topics).\n2.  Run AWS CLI command `aws iot describe-endpoint` to get IoT endpoint url.\n3.  Create `mqttClient` with AWS credentials.\n````js\nimport AWSMqtt from \"aws-mqtt-client\";\n\nconst mqttClient = new AWSMqtt({\n  accessKeyId: AWS_ACCESS_KEY,\n  secretAccessKey: AWS_SECRET_ACCESS_KEY,\n  sessionToken: AWS_SESSION_TOKEN,\n  endpointAddress: AWS_IOT_ENDPOINT_HOST,\n  region: \"us-east-1\"\n});\n````\n4.  Connect and receive messages from your topic.\n````js\nmqttClient.on(\"connect\", () =\u003e {\n  mqttClient.subscribe(\"test-topic\");\n  console.log(\"connected to iot mqtt websocket\");\n});\nmqttClient.on(\"message\", (topic, message) =\u003e {\n  console.log(message.toString());\n});\n````\n5.  Publish a message.\n````js\nmqttClient.publish(MQTT_TOPIC, message);\n````\n\n### Complete [MQTT.js API](https://github.com/mqttjs/MQTT.js#api)\n\n## Credits\nBased on [Serverless JS-Webapp Pub/Sub with AWS IoT](http://stesie.github.io/2016/04/aws-iot-pubsub) article by [Stefan Siegl](https://github.com/stesie). This library is a wrapper around [MQTT.js](https://github.com/mqttjs/MQTT.js) npm package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmyn%2Faws-mqtt-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimmyn%2Faws-mqtt-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmyn%2Faws-mqtt-client/lists"}