{"id":27013976,"url":"https://github.com/iot-thingscloud/thingscloud-mqtt-app-subscribe-nodejs","last_synced_at":"2026-05-09T00:13:03.241Z","repository":{"id":285850835,"uuid":"959555369","full_name":"IoT-ThingsCloud/thingscloud-mqtt-app-subscribe-nodejs","owner":"IoT-ThingsCloud","description":"ThingsCloud MQTT Application-Side Subscription Node.js Example.","archived":false,"fork":false,"pushed_at":"2025-04-03T01:29:54.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-03T02:28:34.507Z","etag":null,"topics":["iot","iot-application","iot-platform","mqtt","nodejs","thingscloud"],"latest_commit_sha":null,"homepage":"https://www.thingscloud.xyz/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IoT-ThingsCloud.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":"2025-04-03T01:17:02.000Z","updated_at":"2025-04-03T01:35:35.000Z","dependencies_parsed_at":"2025-04-03T02:28:37.317Z","dependency_job_id":"d94a3598-bdd9-4a1c-a095-919088727dc2","html_url":"https://github.com/IoT-ThingsCloud/thingscloud-mqtt-app-subscribe-nodejs","commit_stats":null,"previous_names":["iot-thingscloud/thingscloud-mqtt-app-subscribe-nodejs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IoT-ThingsCloud%2Fthingscloud-mqtt-app-subscribe-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IoT-ThingsCloud%2Fthingscloud-mqtt-app-subscribe-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IoT-ThingsCloud%2Fthingscloud-mqtt-app-subscribe-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IoT-ThingsCloud%2Fthingscloud-mqtt-app-subscribe-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IoT-ThingsCloud","download_url":"https://codeload.github.com/IoT-ThingsCloud/thingscloud-mqtt-app-subscribe-nodejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248078882,"owners_count":21044195,"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":["iot","iot-application","iot-platform","mqtt","nodejs","thingscloud"],"created_at":"2025-04-04T13:19:21.561Z","updated_at":"2026-05-09T00:13:03.204Z","avatar_url":"https://github.com/IoT-ThingsCloud.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThingsCloud MQTT 应用端订阅 NodeJS 示例\n\n该示例代码展示了如何使用 ThingsCloud MQTT 应用端订阅服务，通过 NodeJS 语言实现订阅设备消息的功能。\n\n\n## 什么是 MQTT 应用端订阅\n\nThingsCloud 支持开放的 MQTT 应用端订阅服务，帮助您在自有软件应用或第三方应用中实时接收设备的最新消息。\n\n您不仅可以在服务器上订阅设备消息，也可以在基于浏览器的 Web 应用中通过 Javascript 和 MQTT@Websocket 直接订阅设备实时消息，来实现 Web 页面实时更新设备数据，这在开发物联网数据可视化界面时发挥重要的作用。\n\n详细介绍请参考 [MQTT 应用端订阅](https://www.thingscloud.xyz/docs/guide/api/project-mqtt-subscribe.html)。\n\n## 如何运行示例代码\n\n### 安装 NodeJS 和 npm\n\n请确保您的系统已经安装了 Node.js 开发环境。\n\n\n### 下载示例代码\n\nClone 或下载该代码仓库，进入代码目录。\n\n### 安装依赖\n\n```\nnpm install\n```\n\n### 填写配置信息\n\n进入 [ThingsCloud 控制台](https://console.thingscloud.xyz/)，在 **项目 \u003e MQTT 应用端订阅** 中找到以下参数，填写在示例代码中。\n\n- `mqtt_url`：MQTT 地址。\n- `project_view_key`：ProjectViewKey\n- `project_view_secret`：ProjectViewSecret\n\n\n### 运行示例代码\n\n```\nnode app.js\n```\n\n程序运行后，如果填写的参数正确，将提示已成功连接到平台。\n\n![articles/2024/20250403092758_c363faf39cce5f938c3c635d579e9bb7.png](https://img-1300291923.cos.ap-beijing.myqcloud.com/articles/2024/20250403092758_c363faf39cce5f938c3c635d579e9bb7.png)\n\n示例中订阅了所有设备的属性更新消息，您也可以根据实际需求修改订阅的主题。\n\n\n![articles/2024/20250403092845_3930baf6c53e1036a8dc68e104f75f13.png](https://img-1300291923.cos.ap-beijing.myqcloud.com/articles/2024/20250403092845_3930baf6c53e1036a8dc68e104f75f13.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiot-thingscloud%2Fthingscloud-mqtt-app-subscribe-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiot-thingscloud%2Fthingscloud-mqtt-app-subscribe-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiot-thingscloud%2Fthingscloud-mqtt-app-subscribe-nodejs/lists"}