{"id":19211355,"url":"https://github.com/truebrain/truemqtt-cpp","last_synced_at":"2025-07-27T23:35:44.943Z","repository":{"id":60141625,"uuid":"534794976","full_name":"TrueBrain/TrueMQTT-cpp","owner":"TrueBrain","description":"A modern C++ MQTT Client library","archived":false,"fork":false,"pushed_at":"2023-01-07T19:04:49.000Z","size":112,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T17:14:12.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/TrueBrain.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}},"created_at":"2022-09-09T20:24:50.000Z","updated_at":"2022-09-09T20:28:23.000Z","dependencies_parsed_at":"2023-02-07T22:01:54.278Z","dependency_job_id":null,"html_url":"https://github.com/TrueBrain/TrueMQTT-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBrain%2FTrueMQTT-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBrain%2FTrueMQTT-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBrain%2FTrueMQTT-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueBrain%2FTrueMQTT-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueBrain","download_url":"https://codeload.github.com/TrueBrain/TrueMQTT-cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240286517,"owners_count":19777354,"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":[],"created_at":"2024-11-09T13:42:15.073Z","updated_at":"2025-02-23T07:43:46.679Z","avatar_url":"https://github.com/TrueBrain.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrueMQTT - A modern C++ MQTT Client library\n\nThis project is currently a Work In Progress.\n\nAll basic functionality is in there, but it is lacking some QoL functionalities, and it has not really been hardened / battle-tested yet.\n\n## Development\n\nPrepare a build folder:\n\n```bash\nmkdir build\ncd build\n```\n\nInstall dependencies via [conan](https://conan.io/downloads.html):\n\n```bash\nconan install ..\n```\n\nNow you can compile this library:\n\n```bash\ncmake .. -DBUILD_SHARED_LIBS=ON -DMIN_LOGGER_LEVEL=INFO\nmake -j$(nproc)\n\nexample/pubsub/truemqtt_pubsub\n```\n\nOr in case you want to run the regression / code coverage:\n\n```bash\ncmake .. -DBUILD_SHARED_LIBS=ON -DMIN_LOGGER_LEVEL=INFO -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON\nmake -j$(nproc) coverage-html\n```\n\n## Design choices\n\n### MQTT v3 only\n\nAlthough this is a contested choice, for now the library only supports MQTT v3.\nThere is added value in MQTT v5, but it comes with extra overhead, both in performance and memory.\n\nThis library aims to supply an interface for the more common way of using MQTT, which is a simple publish / subscribe interface.\n\nIn the future this might change, because, as said, MQTT v5 has solid additions, that might be worth delving in it.\n\n### Copy-once\n\nA packet that is received from a broker, is only copied once in memory (from `recv()` to an internal buffer).\nAll subscription callbacks get a `std::string_view` which is directly in this buffer.\n\nThis way, the library only needs to allocate memory once, heavily reducing the memory footprint.\nThis also means the library can handle big payloads without issue.\n\nFor publishing a similar approach is taken, and the topic / message is only copied once in an internal buffer.\nThe only exception here is when the client isn't connected to the broker (yet).\nIn this scenario, a copy of topic / message is made, and there will be two allocations for both, instead of one.\n\nEither way, this makes this library highly efficient in terms of memory usage.\n\nThe drawback is that you have to be careful with your callbacks.\nYou always receive a `std::string_view`, that is only valid within that callback.\nAs soon as the callback returns, the memory becomes invalid.\n\nThis means that if you need to keep the topic and/or message around, you need to make a copy.\n\n### QoS 0\n\nThis library only supports QoS 0.\nThis is mainly because that is the only QoS I have ever used since using MQTT.\n\nThe problem with other QoSes is that is is mostly pointless up till the point it is useful.\nMQTT uses TCP, and as such, delivery over the socket is guaranteed if both sides are still alive.\nIn other words, QoS 1 doesn't add any guarantees in the normal situation, where lines / brokers aren't saturated.\nWhen it does get saturated, QoS 1 becomes useful.\n\nBut, there is a trade-off here.\nIf you always do QoS 1 for the cases where the line does get saturated, you put more pressure on the line in all cases, which results in a line that is saturated more quickly.\nAnd in reality, it is very hard to recover from such scenarios anyway.\n\nMQTT 5 corrects this situation, by a bit of a cheat.\nIf you publish with QoS 1, but the TCP connection was working as expected, it in fact handles it as a QoS 0 request.\n\nFor this reason, this library only supports QoS 0.\nAs added benefit, it makes for easier code, which is less like to have bugs / problems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruebrain%2Ftruemqtt-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruebrain%2Ftruemqtt-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruebrain%2Ftruemqtt-cpp/lists"}