{"id":42921075,"url":"https://github.com/andschneider/goqtt","last_synced_at":"2026-01-30T17:37:36.556Z","repository":{"id":57532274,"uuid":"261625464","full_name":"andschneider/goqtt","owner":"andschneider","description":"MQTT 3.1.1 (semi-conformant) library in golang","archived":false,"fork":false,"pushed_at":"2020-10-16T17:35:54.000Z","size":191,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-10T18:14:08.812Z","etag":null,"topics":["go","golang","iot","mqtt","mqtt-client","mqtt-library"],"latest_commit_sha":null,"homepage":"https://andschneider.github.io/goqtt","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/andschneider.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-06T01:47:38.000Z","updated_at":"2020-10-16T17:35:56.000Z","dependencies_parsed_at":"2022-09-05T10:01:01.186Z","dependency_job_id":null,"html_url":"https://github.com/andschneider/goqtt","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/andschneider/goqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andschneider%2Fgoqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andschneider%2Fgoqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andschneider%2Fgoqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andschneider%2Fgoqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andschneider","download_url":"https://codeload.github.com/andschneider/goqtt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andschneider%2Fgoqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28916323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T16:37:38.804Z","status":"ssl_error","status_checked_at":"2026-01-30T16:37:37.878Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","golang","iot","mqtt","mqtt-client","mqtt-library"],"created_at":"2026-01-30T17:37:35.704Z","updated_at":"2026-01-30T17:37:36.529Z","avatar_url":"https://github.com/andschneider.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"left\"\u003e\u003cimg src=\"logo.png\" width=\"300\" height=\"300\"\u003e\u003c/p\u003e\n\n![Build](https://github.com/andschneider/goqtt/workflows/Build/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/andschneider/goqtt)](https://goreportcard.com/report/github.com/andschneider/goqtt)\n[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/andschneider/goqtt)](https://pkg.go.dev/mod/github.com/andschneider/goqtt)\n[![License: MIT](https://img.shields.io/github/license/andschneider/goqtt)](https://img.shields.io/github/license/andschneider/goqtt)\n\n# goqtt\n\ngoqtt is a simple MQTT client library. It is intended for lightweight MQTT applications where security and data guarantees are not important (see [limitations](https://github.com/andschneider/goqtt#limitations) below).\n\n---\n\n## Install\n\nUsing go `1.13` or higher, install using go modules:\n\n`go get github.com/andschneider/goqtt`\n\n## Usage\n\n### subscription\n\nBelow is an example showing how to subscribe to a specified topic. Any Publish message received on the topic will be returned, allowing for further processing if desired.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/andschneider/goqtt\"\n)\n\nfunc main() {\n\t// Create Client\n\ttopic := goqtt.Topic(\"goqtt\")\n\tclient := goqtt.NewClient(\"mqtt.eclipse.org\", topic)\n\n\t// Connect to the specified MQTT broker\n\terr := client.Connect()\n\tif err != nil {\n\t\tlog.Fatalf(\"could not connect to broker: %v\\n\", err)\n\t}\n\tdefer client.Disconnect()\n\n\t// Subscribe to the topic\n\terr = client.Subscribe()\n\tif err != nil {\n\t\tlog.Fatalf(\"could not subscribe to topic: %v\\n\", err)\n\t}\n\n\t// Read messages indefinitely\n\tfor {\n\t\tlog.Println(\"waiting for message\")\n\t\tm, err := client.ReadLoop()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"error when reading in message: %v\\n\", err)\n\t\t}\n\t\tif m != nil {\n\t\t\tlog.Printf(\"received message: '%s' from topic: '%s'\", string(m.Message), m.Topic)\n\t\t}\n\t}\n}\n```\n\n### publish\n\nBelow is an example showing how to Publish a message to a specified topic.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/andschneider/goqtt\"\n)\n\nfunc main() {\n\t// Create Client\n\ttopic := goqtt.Topic(\"goqtt\")\n\tclient := goqtt.NewClient(\"mqtt.eclipse.org\", topic)\n\n\t// Connect to the specified MQTT broker\n\terr := client.Connect()\n\tif err != nil {\n\t\tlog.Fatalf(\"could not connect to broker: %v\\n\", err)\n\t}\n\tdefer client.Disconnect()\n\n\t// Publish a message to the topic\n\terr = client.Publish(\"hello world\")\n\tif err != nil {\n\t\tlog.Printf(\"could not send message: %v\\n\", err)\n\t}\n}\n```\n\n### more \n\nThere are more examples in the `examples` folder. They have more client options exposed and produce verbose logging:\n\n- connect and disconnect to a broker\n- publishing a message a topic\n- subscribing to a topic\n\n#### Go\n\nIf you have Go installed you can run them with `go run ./examples/\u003cexample\u003e`.\n\n#### CLI\n\nIf you don't have Go installed, the examples have been compiled to binaries for Linux (x86 and Arm) and Darwin (macOS). These can found in the [releases](https://github.com/andschneider/goqtt/releases) page. Download the correct .tar.gz for your platform and once uncompressed, the binaries will be in an `examples` folder. These are CLIs and can be ran directly from your terminal. \n\n#### Docker\n\nEach example has a Dockerfile if you don't have Go installed (and have Docker installed). To build an image, run `docker build -t \u003cimage-name\u003e .` from an example directory. \n\nFor example, from the `examples/connect` directory run `docker build -t conngoqtt .`. Then to use the container, run `docker run conngoqtt`.\n\n## Limitations\n\nCurrently, goqtt does not implement the full [MQTT 3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html) client specification. \n\nThe two main omissions from the spec are packets with **QoS \u003e 0** and **username/password** message payloads in CONNECT packets. Because of these, **goqtt should be used with care in any environment that requires sensitive or important data**.\n\n### QoS\n\nFor detailed information please refer to the spec, but with QoS set at 0 each packet is sent *at most once*. To quote the spec:\n\n\u003e The message is delivered according to the capabilities of the underlying network. No response is sent by the receiver and no retry is performed by the sender. The message arrives at the receiver either once or not at all.\n  \nIf a packet is encountered by goqtt with a higher QoS it will likely crash.\n\n### Authentication/Security\n\nWithout any support for username and password information to be sent to a broker there is no way for a client to authenticate. Please carefully consider if this is an acceptable security risk for your use case.\n\nThe MQTT spec does not require the use of TLS/SSL, however there are brokers that support TLS. **goqtt does not support TLS connections.**  Please carefully consider if this is an acceptable security risk for your use case.\n\n### Other\n\nA more minor omission is the lack of support for multiple topic subscriptions or wildcard subscriptions. A topic must be fully formed, e.g. `goqtt/hello`.\n\n## Logging\n\n*WIP*\n\ngoqtt uses [zerolog](https://github.com/rs/zerolog) internally for creating structured logs with different levels (such as DEBUG, INFO, and ERROR). \n\nHowever, all log statements are **disabled** by default. If you'd like to enable the logging, set the global log level to the desired level. This is done with the `zerolog.SetGlobalLevel()` function and a parameter such as `zerolog.InfoLevel`. See the examples and their documentation for more levels.\n\n## Inspiration\n\nThe [eclipse paho golang](https://github.com/eclipse/paho.mqtt.golang) MQTT library has been a large inspiration and resource for this project. Much thanks to them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandschneider%2Fgoqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandschneider%2Fgoqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandschneider%2Fgoqtt/lists"}