{"id":17124330,"url":"https://github.com/vincentdephily/mqttest","last_synced_at":"2025-06-15T05:36:41.125Z","repository":{"id":57640893,"uuid":"228905480","full_name":"vincentdephily/mqttest","owner":"vincentdephily","description":"An MQTT server designed for unittesting MQTT clients.","archived":false,"fork":false,"pushed_at":"2024-07-29T11:42:29.000Z","size":278,"stargazers_count":20,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T02:09:19.834Z","etag":null,"topics":["mqtt","server","test","unittest"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vincentdephily.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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":"2019-12-18T19:12:33.000Z","updated_at":"2024-11-11T22:56:48.000Z","dependencies_parsed_at":"2024-05-20T15:26:01.432Z","dependency_job_id":null,"html_url":"https://github.com/vincentdephily/mqttest","commit_stats":{"total_commits":70,"total_committers":1,"mean_commits":70.0,"dds":0.0,"last_synced_commit":"8e7f18d01a91a7422a5324c205cc8a99f91ec352"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentdephily%2Fmqttest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentdephily%2Fmqttest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentdephily%2Fmqttest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentdephily%2Fmqttest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincentdephily","download_url":"https://codeload.github.com/vincentdephily/mqttest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654090,"owners_count":21140236,"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":["mqtt","server","test","unittest"],"created_at":"2024-10-14T18:42:23.826Z","updated_at":"2025-04-13T02:09:49.294Z","avatar_url":"https://github.com/vincentdephily.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT test server\n\nMqttest is an [MQTT](https://mqtt.org/) server designed for unittesting clients.\n\nCompared to a standard server like Mosquitto, Mqttest brings a CI-friendly binary, fast RC-free\ntests, detailed machine-readable packet dumps, network problem simulations, selectable implementaion\nquirks, running the server as a library, etc.\n\nInitial development has been sponsored by [Munic](https://munic.io/).\n\n## Current and planned features\n\n- Simplified CI image\n  - [x] Automatic open port discovery (simplifies parallel test execution)\n  - [x] Statically-built single-file CLI binary (no runtime deps or fancy install)\n  - [x] Use as a rust library\n    - [x] Decode file dumps to rust structs\n    - [x] Configure and start server\n    - [x] Runtime server control and client interaction using rust channels\n    - [ ] Return dumps and stats after each run\n  - [ ] Use as a library from other languages\n- Verbose log file and network dump\n  - [x] No need for RC-prone connection of an observer client\n  - [x] Json dump of mqtt packet data and metadata (time, connection id...)\n  - [x] Global or per-connection dump filename\n  - [ ] Flexible payload decoding\n- Controllable connection behaviors:\n  - [x] Ack delay\n  - [x] Close connection after a number of packets or a timeout\n  - [ ] Go offline\n  - [ ] Bad packet flow (spurious/missing ack/publish)\n  - [x] Override session lifetime\n  - [x] Reject clients by id or password\n  - [ ] Different pid-assignment strategies\n  - [x] Different behavior for subsequent connections\n  - [x] Stop server after a number of connections\n  - [ ] Stop server after a max runtime\n  - [ ] [Your useful behavior here](https://github.com/vincentdephily/mqttest/issues)\n- Protocol support\n  - [x] MQTT 3.1.1\n  - [ ] MQTT 5\n  - [ ] IPv6\n  - [ ] TLS\n  - [x] Warn about or reject extended client identifiers\n  - [x] Warn about MQTT3 idioms obsoletted by MQTT5\n  - [x] Documentation highlights MQTT implementation gotchas\n\nSome \"missing\" features may already be partially implemented. They will be marked as done when fully\ndone.\n\n## Non-features\n\n* Codec-level errors (better to unittest this at the codec library level).\n* Wildcard topics (at least for now - not useful ?).\n* Database or clustering support (offtopic).\n* High performance/scalability (though aim to be small and fast).\n\n## Usage\n\nInstall [Rust](https://rust-lang.org/) \u003e= 1.39.0 if necessary.\n\n### Standalone binary\n\n```shell\n# Build and install the executable\ncargo install --path .\n\n# See help\nmqttest -h\n```\n\nMqttest starts in just a few milliseconds. You can start a server with a different behaviour for\neach of your client unittest. Or you can start a single instance and leave it running while you do\nsome ad-hoc testing.\n\n### Rust library\n\nIn your `Cargo.toml`:\n\n```toml\n[dev-dependencies]\n# MQTT test server.\nmqttest = { version = \"0.2.0\", default-features = false }\n# mqttest needs to be started from a tokio async context.\ntokio = \"0.2\"\n# At your discretion, if you want to see server logs.\nenv_logger = \"0.7\"\n```\n\nIn your unittests (see [`test.rs`](src/test.rs) for more detailed examples) :\n\n```rust\n/// Boiler-plate to run and log async code from a unittest.\nfn block_on\u003cT\u003e(f: impl Future\u003cOutput = T\u003e) -\u003e T {\n    let _ = env_logger::builder().is_test(true).parse_filters(\"debug\").try_init();\n    tokio::runtime::Builder::new().basic_scheduler().enable_all().build().unwrap().block_on(f)\n}\n\n/// Example unittest. Bring your own client.\n#[test]\nfn connect() {\n    let stats = block_on(async {\n        // Create a server config\n        let conf = Conf::new().max_connect(1);\n        // Start the server\n        let srv = Mqttest::start(conf).await.expect(\"Failed listen\").await;\n        // Start your client on the port that the server selected\n        client::start(srv.port).await.expect(\"Client failure\");\n        // Wait for the server to finish\n        srv.finish().await.unwrap()\n    });\n    // Check run results\n    assert_eq!(1, stats.conn_count);\n}\n```\n\n### Optional features\n\n#### `cli`\n\nRequired to build the binary (as opposed to the library). Enabled by default.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentdephily%2Fmqttest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincentdephily%2Fmqttest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentdephily%2Fmqttest/lists"}