{"id":13413597,"url":"https://github.com/DrmagicE/gmqtt","last_synced_at":"2025-03-14T19:32:49.743Z","repository":{"id":37678069,"uuid":"148990231","full_name":"DrmagicE/gmqtt","owner":"DrmagicE","description":"Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.x and V5 in golang","archived":false,"fork":false,"pushed_at":"2023-11-10T07:56:29.000Z","size":1269,"stargazers_count":987,"open_issues_count":13,"forks_count":218,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-10-17T16:31:43.657Z","etag":null,"topics":["gmqtt","golang","mqtt","mqtt-broker","mqtt-protocol","mqtt-server","server"],"latest_commit_sha":null,"homepage":"","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/DrmagicE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2018-09-16T11:46:17.000Z","updated_at":"2024-10-14T08:51:43.000Z","dependencies_parsed_at":"2022-07-09T13:30:34.506Z","dependency_job_id":"2ab7131c-113d-4527-860a-761ee313d8ad","html_url":"https://github.com/DrmagicE/gmqtt","commit_stats":{"total_commits":274,"total_committers":15,"mean_commits":"18.266666666666666","dds":"0.26277372262773724","last_synced_commit":"61e59bcdc12d5c021fc8df15c33d58be1f2a6873"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrmagicE%2Fgmqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrmagicE%2Fgmqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrmagicE%2Fgmqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DrmagicE%2Fgmqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DrmagicE","download_url":"https://codeload.github.com/DrmagicE/gmqtt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221498771,"owners_count":16833059,"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":["gmqtt","golang","mqtt","mqtt-broker","mqtt-protocol","mqtt-server","server"],"created_at":"2024-07-30T20:01:44.118Z","updated_at":"2024-10-26T05:31:10.528Z","avatar_url":"https://github.com/DrmagicE.png","language":"Go","funding_links":[],"categories":["Networking","网络","Go","网络相关库","Relational Databases"],"sub_categories":["Uncategorized","Transliteration","Strings","音译","Advanced Console UIs","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","暂未分类"],"readme":"[中文文档](https://github.com/DrmagicE/gmqtt/blob/master/README_ZH.md)\n# Gmqtt [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)  ![Build Status](https://github.com/DrmagicE/gmqtt/actions/workflows/test.yml/badge.svg) [![codecov](https://codecov.io/gh/DrmagicE/gmqtt/branch/master/graph/badge.svg)](https://codecov.io/gh/DrmagicE/gmqtt) [![Go Report Card](https://goreportcard.com/badge/github.com/DrmagicE/gmqtt)](https://goreportcard.com/report/github.com/DrmagicE/gmqtt)\n\n# Project state\nThis project is less maintained due to personal reasons. Here are some information for people who want to use this project.\n\nGmqtt was used in production and worked well. The production environment was serving hundreds of clients(or maybe thousands or 10 thousands now), and \neach client published QoS 1 message to report their state every 15 seconds. The subscribers on the cloud would store those state into persist backend.\nAll clients were non-persistent session and using v3.1.1 protocol.\n\nIt is suggested to evaluate and test carefully before running in your production environment.\n\n\n# Features\n* Provide hook method to customized the broker behaviours(Authentication, ACL, etc..). See `server/hooks.go` for details\n* Support tls/ssl and websocket\n* Provide flexible plugable mechanism. See `server/plugin.go` and `/plugin` for details.\n* Provide Go interface for extensions to interact with the server. For examples, the extensions or plugins can publish message or add/remove subscription through function call.\nSee `Server` interface in `server/server.go` and [admin](https://github.com/DrmagicE/Gmqtt/blob/master/plugin/admin/README.md) for details.\n* Provide metrics (by using Prometheus). (plugin: [prometheus](https://github.com/DrmagicE/gmqtt/blob/master/plugin/prometheus/README.md))\n* Provide GRPC and REST APIs to interact with server. (plugin:[admin](https://github.com/DrmagicE/gmqtt/blob/master/plugin/admin/README.md))\n* Provide session persistence which means the broker can retrieve the session data after restart. \nCurrently, only redis backend is supported.\n* Provide clustering, see [federation plugin](./plugin/federation/README.md) for examples and details. (WARNING: This is an experimental feature, and has never been used in production environment.)\n\n\n# Get Started\nTo get started with gmqtt, we need to compile it from the source code. Please ensure that you have a working\nGo environment.\n \nThe following command will start gmqtt broker with default configuration.\nThe broker listens on 1883 for tcp server and 8883 for websocket server with `admin` and `prometheus` plugin loaded.\n\n```bash\n$ git clone https://github.com/DrmagicE/gmqtt\n$ cd gmqtt/cmd/gmqttd\n$ go run . start -c default_config.yml\n```\n\n## configuration\nGmqtt use `-c` flag to define configuration path. If not set, gmqtt reads `$HOME/gmqtt.yml` as default.  Here is a [sample configuration](https://github.com/DrmagicE/gmqtt/blob/master/cmd/gmqttd/default_config.yml).\n\n## session persistence\nGmqtt uses memory to store session data by default and it is the recommended way because of the good performance.\nBut the session data will be lose after the broker restart. You can use redis as backend storage to prevent data \nloss from restart: \n```yaml\npersistence:\n  type: redis  \n  redis:\n    # redis server address\n    addr: \"127.0.0.1:6379\"\n    # the maximum number of idle connections in the redis connection pool\n    max_idle: 1000\n    # the maximum number of connections allocated by the redis connection pool at a given time.\n    # If zero, there is no limit on the number of connections in the pool.\n    max_active: 0\n    # the connection idle timeout, connection will be closed after remaining idle for this duration. If the value is zero, then idle connections are not closed\n    idle_timeout: 240s\n    password: \"\"\n    # the number of the redis database\n    database: 0\n```\n\n## Authentication\nGmqtt provides a simple username/password authentication mechanism. (Provided by [auth](https://github.com/DrmagicE/gmqtt/blob/master/plugin/auth) plugin).\nIt is not enabled in default configuration, you can change the configuration to enable it:\n```yaml\n# plugin loading orders\nplugin_order:\n  - auth\n  - prometheus\n  - admin\n```\nWhen auth plugin enabled, every clients need an account to get connected.You can add accounts through the HTTP API: \n```bash\n# Create: username = user1, password = user1pass\n$ curl -X POST -d '{\"password\":\"user1pass\"}' 127.0.0.1:8083/v1/accounts/user1\n{}\n# Query\n$ curl 127.0.0.1:8083/v1/accounts/user1\n{\"account\":{\"username\":\"user1\",\"password\":\"20a0db53bc1881a7f739cd956b740039\"}}\n```\nAPI Doc [swagger](https://github.com/DrmagicE/gmqtt/blob/master/plugin/auth/swagger)\n\n\n## Docker\n```\n$ docker build -t gmqtt .\n$ docker run -p 1883:1883 -p 8883:8883 -p 8082:8082 -p 8083:8083  -p 8084:8084  gmqtt\n```\n\n# Documentation\n[godoc](https://www.godoc.org/github.com/DrmagicE/gmqtt)\n## Hooks\nGmqtt implements the following hooks: \n\n| Name | hooking point | possible usages  |\n|------|------------|------------|\n| OnAccept  | When accepts a TCP connection.(Not supported in websocket)| Connection rate limit, IP allow/block list. |\n| OnStop  | When gmqtt stop |    |\n| OnSubscribe  | When received a subscribe packet | Subscribe access control, modifies subscriptions. |\n| OnSubscribed  | When subscribe succeed   |     |\n| OnUnsubscribe  |  When received a unsubscribe packet | Unsubscribe access controls, modifies the topics that is going to unsubscribe.|\n| OnUnsubscribed  | When unsubscribe succeed     |        |\n| OnMsgArrived  | When received a publish packet  |  Publish access control, modifies message before delivery.|\n| OnBasicAuth  | When received a connect packet without AuthMethod property | Authentication      |\n| OnEnhancedAuth  | When received a connect packet with AuthMethod property (Only for v5 clients) | Authentication      |\n| OnReAuth  | When received a auth packet (Only for v5 clients)        | Authentication      |\n| OnConnected  | When the client connected succeed|      | \n| OnSessionCreated  | When creates a new session       |         |\n| OnSessionResumed  | When resumes from old session    |        |\n| OnSessionTerminated  | When session terminated       |        |\n| OnDelivered  | When a message is delivered to the client     |        |\n| OnClosed  | When the client is closed  |        |\n| OnMsgDropped  | When a message is dropped for some reasons|        |\n| OnWillPublish | When the client is going to deliver a will message | Modify or drop the will message |\n| OnWillPublished| When a will message has been delivered| |\n\n\n## How to write plugins\n[How to write plugins](https://github.com/DrmagicE/gmqtt/blob/master/plugin/README.md)\n\n# Contributing\nContributions are always welcome, see [Contribution Guide](https://github.com/DrmagicE/gmqtt/blob/master/CONTRIBUTING.md) for a complete contributing guide.\n\n# Test\n## Unit Test\n```\n$ go test -race ./...\n```\n\n## Integration Test\n[paho.mqtt.testing](https://github.com/eclipse/paho.mqtt.testing).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDrmagicE%2Fgmqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDrmagicE%2Fgmqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDrmagicE%2Fgmqtt/lists"}