{"id":16880630,"url":"https://github.com/squaremo/erlmqtt","last_synced_at":"2025-07-06T18:04:40.215Z","repository":{"id":66130705,"uuid":"1919565","full_name":"squaremo/erlmqtt","owner":"squaremo","description":"MQTT library for Erlang *JUST USABLE*","archived":false,"fork":false,"pushed_at":"2014-05-08T15:40:38.000Z","size":793,"stargazers_count":27,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T08:11:03.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/squaremo.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":"2011-06-19T14:48:04.000Z","updated_at":"2024-11-01T06:31:05.000Z","dependencies_parsed_at":"2023-02-19T23:00:49.578Z","dependency_job_id":null,"html_url":"https://github.com/squaremo/erlmqtt","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/squaremo%2Ferlmqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squaremo%2Ferlmqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squaremo%2Ferlmqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squaremo%2Ferlmqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squaremo","download_url":"https://codeload.github.com/squaremo/erlmqtt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248387205,"owners_count":21095168,"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-10-13T15:59:34.770Z","updated_at":"2025-04-11T11:44:33.687Z","avatar_url":"https://github.com/squaremo.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"erlmqtt\n=======\n\nAn Erlang client library for MQTT 3.1 (but not for MQTT 3.1.1, yet).\n\n### Building\n\n    $ make\n\n### Testing\n\n    $ make test \u0026\u0026 make dialyse\n\n### Trying out\n\nThis API may change, especially with respect to receiving messages.\n\n(Assuming RabbitMQ or another MQTT broker is running on localhost:1883)\n\n    $ erl -pa ebin\n\n*Opening a connection and subscribing*\n\n```erlang\n1\u003e {ok, C} = erlmqtt:open_clean(\"localhost\", []).\n{ok,\u003c0.35.0\u003e}\n2\u003e {ok, _} = erlmqtt:subscribe(C, [{\"topic/#\", at_most_once}]).\n{ok,[at_most_once]}\n```\n\n`open_clean` starts a fresh connection that doesn't keep state around\nwhen disconnected. The second argument is a proplist of options, for\nexample, `[{keep_alive, 600}]`.\n\nAlso exported are `open/2` and `open/3`, which start connections with\npersistent state (though resumption of those after disconnection is\nnot fully implemented yet).\n\n*Publishing messages*\n\n```erlang\n3\u003e erlmqtt:publish(C, \"topic/a/b\", \u003c\u003c\"payload\"\u003e\u003e).\nok\n```\n\nThere's also a `publish/4` which accepts a proplist of options, e.g.,\n`[retain, at_least_once]`, and `publish_sync/4` and `publish_sync/5`,\nwhich publish a message using guaranteed delivery and return when the\nmessage has been delivered (or in the case of `publish_sync/5`, if it\nhas timed out).\n\n```erlang\n4\u003e erlmqtt:publish_sync(C, \"/dev/null\", \u003c\u003c\"payload\"\u003e\u003e, at_least_once).\nok\n```\n\nCurrently, using \"quality of service\" (guaranteed delivery) other than\n`at_most_once` does not get you a lot; the connection will enact the\ncorrect protocol, but if it crashes you will still lose the state.\n\n*Receiving messages*\n\n```erlang\n5\u003e erlmqtt:recv_message(1000).\n{\u003c\u003c\"topic/a/b\"\u003e\u003e,\u003c\u003c\"payload\"\u003e\u003e}\n6\u003e erlmqtt:recv_message(1000).\ntimeout\n7\u003e erlmqtt:publish(C, \"topic/foo\", \u003c\u003c\"payload\"\u003e\u003e).\n8\u003e erlmqtt:poll_message().\n{\u003c\u003c\"topic/foo\"\u003e\u003e,\u003c\u003c\"payload\"\u003e\u003e}\n9\u003e erlmqtt:poll_message().\nnone\n```\n\nWhen a connection is opened, the calling process is volunteered as the\nmessage consumer. This means the connection will deliver messages to\nits mailbox. `recv_message/0` and `recv_message/1` wait for a message\nto arrive (in the latter case, for a limited time) and return it as a\npair of topic and payload. `poll_message/0` returns a pair of topic\nand payload if a message is available in the mailbox now, otherwise\n`'none'`.\n\n### Examples\n\nThe scripts `erlmqtt_pub` and `erlmqtt_sub` give examples of publishing\nand subscribing respectively. Presently they must be run from the\nrepository directory. Use the argument `--help` with either to see its\nusage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquaremo%2Ferlmqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquaremo%2Ferlmqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquaremo%2Ferlmqtt/lists"}