You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ MQTTNIO is a Swift NIO based implementation of a MQTT client. It supports
14
14
- WebSocket connections
15
15
- Posix sockets
16
16
- Apple's Network framework via [NIOTransportServices](https://github.com/apple/swift-nio-transport-services) (required for iOS).
17
+
- Unix domain sockets
17
18
18
19
You can find documentation for MQTTNIO
19
20
[here](https://swift-server-community.github.io/mqtt-nio/documentation/mqttnio/). There is also a sample demonstrating the use MQTTNIO in an iOS app found [here](https://github.com/adam-fowler/EmCuTeeTee)
Copy file name to clipboardExpand all lines: Sources/MQTTNIO/MQTTNIO.docc/mqttnio-connections.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Connections
2
2
3
-
Support for TLSand WebSockets.
3
+
Support for TLS, WebSockets, and Unix Domain Sockets.
4
4
5
5
## TLS
6
6
@@ -31,3 +31,23 @@ MQTT also supports Web Socket connections. Provide a `WebSocketConfiguration` wh
31
31
## NIO Transport Services
32
32
33
33
On macOS and iOS you can use the NIO Transport Services library (NIOTS) and Apple's `Network.framework` for communication with the MQTT broker. If you don't provide an `eventLoopGroup` or a `TLSConfigurationType` then this is the default for both platforms. If you do provide either of these then the library will base it's decision on whether to use NIOTS or NIOSSL on what you provide. Provide a `MultiThreadedEventLoopGroup` or `NIOSSL.TLSConfiguration` and the client will use NIOSSL. Provide a `NIOTSEventLoopGroup` or `TSTLSConfiguration` and the client will use NIOTS. If you provide a `MultiThreadedEventLoopGroup` and a `TSTLSConfiguration` then the client will throw an error. If you are running on iOS you should always choose NIOTS.
34
+
35
+
## Unix Domain Sockets
36
+
37
+
MQTT NIO can connect to a local MQTT broker via a Unix Domain Socket.
38
+
39
+
```swift
40
+
let client =MQTTClient(
41
+
unixSocketPath: "/path/to/broker.socket",
42
+
identifier: "UDSClient",
43
+
eventLoopGroupProvider: .createNew
44
+
)
45
+
```
46
+
47
+
Under the hood, `MQTTClient.port` will be 0 and `MQTTClient.host` will be the specified unix socket path when connecting to a unix socket.
48
+
49
+
Note that mosquitto supports listening on a unix domain socket. This can be enabled by adding a `listener` option to the mosquitto config.
A local mosquitto server using `mosquitto/config/mosquitto.conf` will create a `mosquitto.sock` socket in this directory.
2
+
3
+
If using the `docker-compose.yml` container environment, a shared container volume will be mounted here.
4
+
5
+
This allows tests that connect to mosquitto via unix domain socket to assume the socket(s) will be found in this directory and work from multiple environments.
0 commit comments