{"id":13753216,"url":"https://github.com/hb-chen/gmqtt","last_synced_at":"2025-10-04T00:10:34.638Z","repository":{"id":57487915,"uuid":"133653393","full_name":"hb-chen/gmqtt","owner":"hb-chen","description":"Golang MQTT Broker.","archived":false,"fork":false,"pushed_at":"2023-02-25T03:06:58.000Z","size":959,"stargazers_count":81,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-26T16:44:18.218Z","etag":null,"topics":["broker","im","iot","kafka","microservice","mq","mqtt","mqtt-proxy"],"latest_commit_sha":null,"homepage":"http://gmqtt.k8s.hbchen.com:80","language":"Go","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/hb-chen.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}},"created_at":"2018-05-16T11:07:57.000Z","updated_at":"2025-02-25T03:01:56.000Z","dependencies_parsed_at":"2023-07-15T04:17:16.381Z","dependency_job_id":null,"html_url":"https://github.com/hb-chen/gmqtt","commit_stats":null,"previous_names":["hb-chen/micro-mq","hb-go/micro-mq"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hb-chen/gmqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hb-chen%2Fgmqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hb-chen%2Fgmqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hb-chen%2Fgmqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hb-chen%2Fgmqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hb-chen","download_url":"https://codeload.github.com/hb-chen/gmqtt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hb-chen%2Fgmqtt/sbom","scorecard":{"id":458341,"data":{"date":"2025-08-11","repo":{"name":"github.com/hb-chen/gmqtt","commit":"89754d30e5b95d5f7ca322b4cd8ad96b85791b34"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/hb-chen/gmqtt/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/hb-chen/gmqtt/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/hb-chen/gmqtt/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/hb-chen/gmqtt/go.yml/master?enable=pin","Warn: containerImage not pinned by hash: gateway/Dockerfile:1: pin your Docker image by updating alpine:3.10 to alpine:3.10@sha256:451eee8bedcb2f029756dc3e9d73bab0e7943c1ac55cff3a4861c52a0fdd3e98","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:17","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T10:23:14.613Z","repository_id":57487915,"created_at":"2025-08-19T10:23:14.613Z","updated_at":"2025-08-19T10:23:14.613Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278245457,"owners_count":25955028,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["broker","im","iot","kafka","microservice","mq","mqtt","mqtt-proxy"],"created_at":"2024-08-03T09:01:18.470Z","updated_at":"2025-10-04T00:10:34.601Z","avatar_url":"https://github.com/hb-chen.png","language":"Go","funding_links":[],"categories":["kafka"],"sub_categories":[],"readme":"# Micro MQ\n以微服务+MQ构建支持高并发连接的分布式消息服务系统\n\n\u003e [消息持久化及写放大模式设计](https://github.com/hb-chen/gmqtt/issues/1#issuecomment-518517597)\n\n![micro-mq](/doc/img/architecture.jpg \"micro-mq\")\n\n- Gateway节点`Node`通过订阅MQ消息的方式，完成消息在节点间的转发\n- 根据业务场景的需求，需要考虑Node节点消息消费与生产速度的匹配\n    - Client间的pub/sub关系比较多，如`n`个node, 发送`m`条消息/topic/node，节点消费的需求是`n`*`m`条/topic\n    - Client端多为pub操作，而系统下发消息较少的情况，节点消费需求则比较低\n    \nGateway编程模型\n\n![micro-mq](/doc/img/gateway_model.jpg \"gateway_modem\")\n### Features\n\n## 运行\n#### 服务依赖\n\u003e 根据配置选择 conf/conf.toml\n- MQ `conf.broker`\n    - [x] Kafka \n- 服务注册与发现 `conf.auth`\n    - [x] Etcd\n    - [ ] Consul\n    \n#### 启动服务\n```bash\n# 启动Gateway，[-h]帮助查看可选参数\n$ cd gateway\n$ go run -tags \"consul\" main.go\n\n# RPC Auth服务，[-h]帮助查看可选参数\n$ cd api\n$ go run -tags \"consul\" main.go\n```\n\n#### 在线演示\n- [MQTT Web Client](http://mqtt-client.hbchen.com/)\n  - [Github源码](https://github.com/hb-chen/hivemq-mqtt-web-client)\n- Gateway 测试服务\n  - `host`=`gmqtt.k8s.hbchen.com`\n  - `port`=`80`\n\n## 组件\n- gateway\n    - sessions\n        - [x] mock\n        - [x] redis\n    - topic\n        - [x] mem\n    - client auth\n        - [x] mock\n        - [x] rpc\n    - pub/sub auth\n        - [ ] mock\n        - [ ] rpc\n- broker\n    - [x] kafka\n    \n- \u003e Developing\n    - api\n        - auth\n            - [ ] RPC服务间的访问控制：RBAC\n        - client\n            - auth\n                - [x] client auth\n                - [ ] pub/sub auth\n            - register\n                - [ ] register\n                - [ ] unregister\n        - cluster\n            - nodes\n                - 节点列表\n            - clients\n                - 终端列表\n            - sessions\n                - 会话列表\n            - topics\n                - 话题信息\n            - subscriptions\n                - 订阅信息\n    - console\n    - deploy\n\n## Frameworks\n- [rpcx](https://github.com/smallnest/rpcx)\n- [Echo](https://github.com/labstack/echo)\n\n## Benchmark\n- MBP开发环境\n- mock broker\n- pub timeout 3000 ms, size 64\n```bash\n$ go test -run=TestClient$\n# 1 client pub, sent 100000 messages, no sub\n# qos 0\nTotal sent 100000 messages dropped 0 in 3096.074512 ms, 0.030961 ms/msg, 32298 msgs/sec\n# qos 1\nTotal sent 100000 messages dropped 0 in 10411.318733 ms, 0.104113 ms/msg, 9604 msgs/sec\n```\n```bash\n$ go test -run=TestClients$\n# 1000 clients, sent 1000 messages/client, no sub\n# qos 0\nTotal Sent 1000000 messages dropped 0 in 14628.666153 ms, 0.014629 ms/msg, 68358 msgs/sec\n# qos 1\nTotal Sent 1000000 messages dropped 0 in 38669.812430 ms, 0.038670 ms/msg, 25859 msgs/sec\n\n# 1000 clients, sent 1000 messages/client, 1 client sub\n# qos 1\nTotal Sent 1000000 messages dropped 0 in 65403.199238 ms, 0.065403 ms/msg, 15289 msgs/sec\nTotal Received 1000000 messages in 65403.199238 ms, 0.065403 ms/msg, 15289 msgs/sec\n# qos 2\nTotal Sent 1000000 messages dropped 0 in 68339.624216 ms, 0.068340 ms/msg, 14632 msgs/sec\nTotal Received 1000000 messages in 68339.624216 ms, 0.068340 ms/msg, 14632 msgs/sec\n```\n\n## 备用命令\n#### Protobuf\n```bash\n# 在.proto有import时注意相对的路径\nprotoc -I=$GOPATH/src:.  --go_out=.  api/proto/define.proto\n```\n#### Kafka\n```bash\n# Start the server\n$ bin/zookeeper-server-start.sh config/zookeeper.properties\n$ bin/kafka-server-start.sh config/server.properties\n\n# List topic\nbin/kafka-topics.sh --list --zookeeper localhost:2181\n\n# Start a consumer\nbin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic --from-beginning\n```\n#### Kafka Manager\n```bash\n# 启动报错，需修改conf/application.conf\nkafka-manager.zkhosts=\"localhost:2181\"\n```\n\n## 参考内容\n- [[转][译]百万级WebSockets和Go语言](https://colobu.com/2017/12/13/A-Million-WebSockets-and-Go/)\n    - [[原]A Million WebSockets and Go](https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb)\n- [SurgeMQ](https://github.com/surgemq/surgemq)\n- [Micro](http://github.com/micro)\n- [Managing IoT devices with Kafka and MQTT](https://www.ibm.com/blogs/bluemix/2017/01/managing-iot-devices-with-kafka-and-mqtt/)\n- [MQTT QoS（服务质量）介绍](https://www.emqx.cn/blog/introduction-to-mqtt-qos)\n- [StreamNative 宣布开源 MoP：Apache Pulsar 支持原生 MQTT 协议](https://segmentfault.com/a/1190000025167243)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhb-chen%2Fgmqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhb-chen%2Fgmqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhb-chen%2Fgmqtt/lists"}