# SSWG-0018: MQTTNIO Proposal

**URL:** <https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004>\
**Category:** Proposals\
**Created:** [December 12, 2021, 1:50am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004 "2021-12-12T01:50:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xTim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/0xtim/32/27968_2.png) [@0xTim](https://forums.swift.org/u/0xTim)\
**Post date:** [December 12, 2021, 1:50am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/1 "2021-12-12T01:50:57Z")

</div>

The review of [SSWG-0018: MQTTNIO](https://github.com/swift-server/sswg/blob/main/proposals/0018-mqtt-nio.md) begins now and runs through December 31, 2021. (Note the extra week due to the holiday period)

Reviews are an important part of the Swift Server Work Group [incubation process](https://github.com/swift-server/sswg/blob/master/process/incubation.md#process). All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager (via [email](mailto:0xtimc@gmail.com) or direct message in the Swift forums).

## What goes into a review of a proposal?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, become listed on the Swift Server Ecosystem [index page](https://swift.org/sswg/#projects).

When reviewing a proposal, here are some questions to consider:

- What is your evaluation of the proposal and its APIs/implementation?
- Is the problem being addressed relevant for the wider Swift on Server ecosystem?
- Does this proposal fit well with the feel and direction of the Swift Server ecosystem?
- If you have used other libraries in Swift or other languages, how do you feel that this proposal compares to those?
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Thanks,  
Tim Condon  
Review Manager

---

<div class="post-metadata">

**Author:** ![johannesweiss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/johannesweiss/32/38183_2.png) [@johannesweiss](https://forums.swift.org/u/johannesweiss)\
**Post date:** [December 13, 2021, 12:41pm UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/2 "2021-12-13T12:41:54Z")

</div>

+1, an MQTT implementation is an important for Swift on the Server.

I didn't spent much time reviewing the protocol in detail but what I saw looks great. Thanks very much @adam-fowler, great work!

---

<div class="post-metadata">

**Author:** ![tomerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tomerd/32/3402_2.png) [@tomerd](https://forums.swift.org/u/tomerd)\
**Post date:** [December 13, 2021, 5:16pm UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/3 "2021-12-13T17:16:11Z")

</div>

+1, MQTT has been on the list of desired server libraries for a long time and would be a great addition to the ecosystem.

---

<div class="post-metadata">

**Author:** ![FranzBusch](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/franzbusch/32/19447_2.png) [@FranzBusch](https://forums.swift.org/u/FranzBusch)\
**Post date:** [December 13, 2021, 8:41pm UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/4 "2021-12-13T20:41:14Z")

</div>

+1 It is an essential library for the Swift on Server ecosystem. I have also used it and it worked great!

---

<div class="post-metadata">

**Author:** ![kmahar](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kmahar/32/5380_2.png) [@kmahar](https://forums.swift.org/u/kmahar)\
**Post date:** [December 15, 2021, 5:40am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/5 "2021-12-15T05:40:56Z")

</div>

+1. Reviewing this is the first I've learned about MQTT so I can't comment much on the low level details here, but I've read through the proposal a couple times and the high level details of MQTT.  
Given it is a standard for IoT such a library definitely seems valuable to the ecosystem, and this one appears to do all the right things in terms of following the feel/direction of other libraries - built atop NIO, `EventLoopFuture` and `async` APIs that follow similar patterns to other libraries, integration with swift-log, cross-platform, etc.

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [December 22, 2021, 1:54am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/6 "2021-12-22T01:54:45Z")

</div>

+1 from me, I'm somewhat familiar with MQTT and it is very popular in some scenarios or communities. Awesome to offer it also in our ecosystem 🙂

No concerns about adopting into Sandbox level.

Minor note: `try await client.subscribe(to: [subscription])` could become an async sequence, but that could just be additional API 🙂

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [December 26, 2021, 8:40am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/7 "2021-12-26T08:40:31Z")

</div>

Konrad do you mean something like this?

```swift
// subscribe to topic
await.client.subscribe(to: [subscription])
// return async sequence of publish messages received from server
let seq = client.createPublishListener()

```

as this is already available

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [December 26, 2021, 8:54am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/8 "2021-12-26T08:54:24Z")

</div>

That’s what I meant yeah, thanks! A bit weird why it is two API calls? The subscribe can return the sequence and we cancel it as one breaks out of the loop etc

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [December 26, 2021, 11:42am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/9 "2021-12-26T11:42:16Z")

</div>

> [@ktoso](#):
>
> That’s what I meant yeah, thanks! A bit weird why it is two API calls? The subscribe can return the sequence and we cancel it as one breaks out of the loop etc

It two separate calls because it's two separate actions really. I know there is a relationship there in that you receive PUBLISH messages based on what subscriptions you setup. But you can also receive PUBLISH messages because you had a subscription setup from a previous session. If the only way to process those messages if via a `subscribe` call the messages from previous sessions could be lost.

Also the `SUBACK` message we wait on after sending the `SUBSCRIBE` message contains information. By just returning an AsyncSequence of messages we lose that information.

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [December 26, 2021, 1:32pm UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/10 "2021-12-26T13:32:26Z")

</div>

I see, thanks for the explanation! Seems i wasn’t fully up to date with how these work 🙂

---

<div class="post-metadata">

**Author:** ![0xTim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/0xtim/32/27968_2.png) [@0xTim](https://forums.swift.org/u/0xTim)\
**Post date:** [January 19, 2022, 10:07am UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/11 "2022-01-19T10:07:10Z")

</div>

Thank you very much, everyone, for your participation in this thread!

I am pleased to announce that the SSWG has voted to accept MQTTNIO at Sandbox level.

@tomerd will lock this thread and add the package to the SSWG package index.

---

<div class="post-metadata">

**Author:** ![tomerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tomerd/32/3402_2.png) [@tomerd](https://forums.swift.org/u/tomerd)\
**Post date:** [January 19, 2022, 6:31pm UTC](https://forums.swift.org/t/sswg-0018-mqttnio-proposal/54004/12 "2022-01-19T18:31:44Z")

</div>


