How connectors work in luamqtt
masterA connector is the network connection layer responsible for establishing a network stream (typically TCP) and handling data transmission (send/receive).
luamqtt includes three standard connectors:
luasocket(mqtt/luasocket.lua)luasocket_ssl(mqtt/luasocket_ssl.lua)ngxsocket(mqtt/ngxsocket.lua) — specifically for use in OpenResty environments.
Default Behavior
The library automatically selects a connector based on the secure option in the client configuration:
- If
secure = true, it usesluasocket_ssl. - If
secure = false, it usesluasocket.
Custom Connectors
You can implement your own connector to make luamqtt work in specialized environments. A connector is simply a set of functions that manage the network stream. Each MQTT client instance can have its own unique connector.