{"id":20062829,"url":"https://github.com/awslabs/aws-c-mqtt","last_synced_at":"2026-02-12T23:09:37.395Z","repository":{"id":33440841,"uuid":"142616481","full_name":"awslabs/aws-c-mqtt","owner":"awslabs","description":"C99 implementation of the MQTT 3.1.1 specification.","archived":false,"fork":false,"pushed_at":"2025-05-12T19:00:13.000Z","size":1874,"stargazers_count":97,"open_issues_count":6,"forks_count":34,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-12T20:21:28.127Z","etag":null,"topics":["hacktoberfest","mqtt"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awslabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2018-07-27T19:32:17.000Z","updated_at":"2025-05-07T21:33:04.000Z","dependencies_parsed_at":"2023-09-27T22:26:00.458Z","dependency_job_id":"7143caa9-8136-4f48-9bd7-e523a784a8f4","html_url":"https://github.com/awslabs/aws-c-mqtt","commit_stats":{"total_commits":237,"total_committers":23,"mean_commits":"10.304347826086957","dds":0.7890295358649789,"last_synced_commit":"0b6c56c42bd48d697d7d12d86e4e8457fd75bce0"},"previous_names":[],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Faws-c-mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Faws-c-mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Faws-c-mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Faws-c-mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awslabs","download_url":"https://codeload.github.com/awslabs/aws-c-mqtt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253815832,"owners_count":21968701,"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":["hacktoberfest","mqtt"],"created_at":"2024-11-13T13:39:00.771Z","updated_at":"2026-02-12T23:09:32.372Z","avatar_url":"https://github.com/awslabs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## AWS C MQTT\n\nC99 implementation of the MQTT 3.1.1 and MQTT 5 specifications.\n\n## License\n\nThis library is licensed under the Apache 2.0 License.\n\n## Usage\n\n### Building\n\nCMake 3.9+ is required to build.\n\n`\u003cinstall-path\u003e` must be an absolute path in the following instructions.\n\n#### Linux-Only Dependencies\n\nIf you are building on Linux, you will need to build aws-lc and s2n-tls first.\n\n```\ngit clone git@github.com:awslabs/aws-lc.git\ncmake -S aws-lc -B aws-lc/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e\ncmake --build aws-lc/build --target install\n\ngit clone git@github.com:aws/s2n-tls.git\ncmake -S s2n-tls -B s2n-tls/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build s2n-tls/build --target install\n```\n\n#### Building aws-c-mqtt and Remaining Dependencies\n\n```\ngit clone git@github.com:awslabs/aws-c-common.git\ncmake -S aws-c-common -B aws-c-common/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e\ncmake --build aws-c-common/build --target install\n\ngit clone git@github.com:awslabs/aws-c-cal.git\ncmake -S aws-c-cal -B aws-c-cal/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build aws-c-cal/build --target install\n\ngit clone git@github.com:awslabs/aws-c-io.git\ncmake -S aws-c-io -B aws-c-io/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build aws-c-io/build --target install\n\ngit clone git@github.com:awslabs/aws-c-compression.git\ncmake -S aws-c-compression -B aws-c-compression/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build aws-c-compression/build --target install\n\ngit clone git@github.com:awslabs/aws-c-http.git\ncmake -S aws-c-http -B aws-c-http/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build aws-c-http/build --target install\n\ngit clone git@github.com:awslabs/aws-c-mqtt.git\ncmake -S aws-c-mqtt -B aws-c-mqtt/build -DCMAKE_INSTALL_PREFIX=\u003cinstall-path\u003e -DCMAKE_PREFIX_PATH=\u003cinstall-path\u003e\ncmake --build aws-c-mqtt/build --target install\n```\n\n### Overview\n\nThis library contains an MQTT implementation that is simple and easy to use, but also quite powerful and low on\nunnecessary copies. Here is a general overview of the API:\n\n### `struct aws_mqtt_client;`\n\n`aws_mqtt_client` is meant to be created once per application to pool common resources required for opening MQTT\nconnections. The instance does not need to be allocated, and may be managed by the user.\n\n```c\nint aws_mqtt_client_init(\n    struct aws_mqtt_client *client,\n    struct aws_allocator *allocator,\n    struct aws_event_loop_group *elg);\n```\nInitializes an instance of `aws_mqtt_client` with the required parameters.\n* `client` is effectively the `this` parameter.\n* `allocator` will be used to initialize the client (note that the client itself is NOT allocated).\n    *This resource must outlive `client`*.\n* `bootstrap` will be used to initiate new socket connections MQTT.\n    *This resource must outlive `client`*.\n    See [aws-c-io][aws-c-io] for more information about `aws_client_bootstrap`.\n\n```c\nvoid aws_mqtt_client_clean_up(struct aws_mqtt_client *client);\n```\nCleans up a client and frees all owned resources.\n\n**NOTE**: DO NOT CALL THIS FUNCTION UNTIL ALL OUTSTANDING CONNECTIONS ARE CLOSED.\n\n### `struct aws_mqtt_client_connection;`\n\n```c\nstruct aws_mqtt_client_connection *aws_mqtt_client_connection_new(\n    struct aws_mqtt_client *client,\n    struct aws_mqtt_client_connection_callbacks callbacks,\n    const struct aws_byte_cursor *host_name,\n    uint16_t port,\n    struct aws_socket_options *socket_options,\n    struct aws_tls_ctx_options *tls_options);\n```\nAllocates and initializes a new connection object (does NOT actually connect). You may use the returned object to\nconfigure connection parameters, and then call `aws_mqtt_client_connection_connect` to actually open the connection.\n* `client` is required in order to use an existing DNS resolver, event loop group, and allocator.\n* `callbacks` provides the connection-level (not operation level) callbacks and the userdata to be given back.\n* `host_name` lists the end point to connect to. This may be a DNS address or an IP address.\n    *This resource may be freed immediately after return.*\n* `port` the port to connect to on `host_name`.\n* `socket_options` describes how to open the connection.\n    See [aws-c-io][aws-c-io] for more information about `aws_socket_options`.\n* `tls_options` provides TLS credentials to connect with. Pass `NULL` to not use TLS (**NOT RECOMMENDED**).\n    See [aws-c-io][aws-c-io] for more information about `aws_tls_ctx_options`.\n\n```c\nvoid aws_mqtt_client_connection_destroy(struct aws_mqtt_client_connection *connection);\n```\nDestroys a connection and frees all outstanding resources.\n\n**NOTE**: DO NOT CALL THIS FUNCTION UNTIL THE CONNECTION IS CLOSED.\n\n```c\nint aws_mqtt_client_connection_set_will(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *topic,\n    enum aws_mqtt_qos qos,\n    bool retain,\n    const struct aws_byte_cursor *payload);\n```\nSets the last will and testament to be distributed by the server upon client disconnection. Must be called before\n`aws_mqtt_client_connection_connect`. See `aws_mqtt_client_connection_publish` for information on the parameters.\n`topic` and `payload` must persist past the call to `aws_mqtt_client_connection_connect`.\n\n```c\nint aws_mqtt_client_connection_set_login(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *username,\n    const struct aws_byte_cursor *password);\n```\nSets the username and password to be sent to the server on connection. Must be called before\n`aws_mqtt_client_connection_connect`. `username` and `password` must persist past the call to\n`aws_mqtt_client_connection_connect`.\n\n```c\nint aws_mqtt_client_connection_set_reconnect_timeout(\n    struct aws_mqtt_client_connection *connection,\n    uint64_t min_timeout,\n    uint64_t max_timeout);\n```\nSets the minimum and maximum reconnect timeouts. The time between reconnect attempts will start at min and multipy by 2\nuntil max is reached.\n\n```c\nint aws_mqtt_client_connection_connect(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *client_id,\n    bool clean_session,\n    uint16_t keep_alive_time);\n```\nConnects to the remote endpoint. The parameters here are set in the MQTT CONNECT packet directly. `client_id` must persist until the `on_connack` connection callback is called.\n\n```c\nint aws_mqtt_client_connection_disconnect(struct aws_mqtt_client_connection *connection);\n```\nCloses an open connection. Does not clean up any resources, that's to be done by `aws_mqtt_client_connection_destroy`,\nprobably from the `on_disconnected` connection callback.\n\n```c\nuint16_t aws_mqtt_client_connection_subscribe_single(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *topic_filter,\n    enum aws_mqtt_qos qos,\n    aws_mqtt_client_publish_received_fn *on_publish,\n    void *on_publish_ud,\n    aws_mqtt_suback_single_fn *on_suback,\n    void *on_suback_ud);\n```\nSubscribes to the topic filter given with the given QoS. `on_publish` will be called whenever a packet matching\n`topic_filter` arrives. `on_suback` will be called when the SUBACK packet has been received. `topic_filter` must persist until `on_suback` is called. The packet_id of the SUBSCRIBE packet will be returned, or 0 on error.\n\n```c\nuint16_t aws_mqtt_client_connection_unsubscribe(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *topic_filter,\n    aws_mqtt_op_complete_fn *on_unsuback,\n    void *on_unsuback_ud);\n```\nUnsubscribes from the topic filter given. `topic_filter` must persist until `on_unsuback` is called. The packet_id of\nthe UNSUBSCRIBE packet will be returned, or 0 on error.\n\n```c\nuint16_t aws_mqtt_client_connection_publish(\n    struct aws_mqtt_client_connection *connection,\n    const struct aws_byte_cursor *topic,\n    enum aws_mqtt_qos qos,\n    bool retain,\n    const struct aws_byte_cursor *payload,\n    aws_mqtt_op_complete_fn *on_complete,\n    void *userdata);\n```\nPublish a payload to the topic specified. For QoS 0, `on_complete` will be called as soon as the packet is sent over\nthe wire. For QoS 1, as soon as PUBACK comes back. For QoS 2, PUBCOMP. `topic` and `payload` must persist until\n`on_complete`.\n\n```c\nint aws_mqtt_client_connection_ping(struct aws_mqtt_client_connection *connection);\n```\nSends a PINGREQ packet to the server.\n\n[aws-c-io]: https://github.com/awslabs/aws-c-io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Faws-c-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawslabs%2Faws-c-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Faws-c-mqtt/lists"}