package
0.23.2
Repository: https://github.com/mainfluxlabs/mainflux.git
Documentation: pkg.go.dev

# README

MQTT adapter

MQTT adapter provides an MQTT API for sending messages through the platform. MQTT adapter uses mProxy for proxying traffic between client and MQTT broker.

Configuration

The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.

VariableDescriptionDefault
MF_MQTT_ADAPTER_LOG_LEVELmProxy Log levelerror
MF_MQTT_ADAPTER_MQTT_PORTmProxy port1883
MF_MQTT_ADAPTER_MQTT_TARGET_HOSTMQTT broker host0.0.0.0
MF_MQTT_ADAPTER_MQTT_TARGET_PORTMQTT broker port1883
MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECKURL of broker health check""
MF_MQTT_ADAPTER_WS_PORTmProxy MQTT over WS port8080
MF_MQTT_ADAPTER_WS_TARGET_HOSTMQTT broker host for MQTT over WSlocalhost
MF_MQTT_ADAPTER_WS_TARGET_PORTMQTT broker port for MQTT over WS8080
MF_MQTT_ADAPTER_WS_TARGET_PATHMQTT broker MQTT over WS path/mqtt
MF_MQTT_ADAPTER_FORWARDER_TIMEOUTMQTT forwarder for multiprotocol communication timeout30s
MF_BROKER_URLMessage broker broker URLnats://127.0.0.1:4222
MF_THINGS_AUTH_GRPC_URLThings gRPC endpoint URLlocalhost:8181
MF_THINGS_AUTH_GRPC_TIMEOUTTimeout in seconds for Things service gRPC calls1s
MF_JAEGER_URLURL of Jaeger tracing service""
MF_MQTT_ADAPTER_CLIENT_TLSgRPC client TLSfalse
MF_MQTT_ADAPTER_CA_CERTSCA certs for gRPC client TLS""
MF_MQTT_ADAPTER_INSTANCEInstance name for event sourcing""
MF_MQTT_ADAPTER_ES_URLEvent sourcing URLlocalhost:6379
MF_MQTT_ADAPTER_ES_PASSEvent sourcing password""
MF_MQTT_ADAPTER_ES_DBEvent sourcing database"0"
MF_AUTH_CACHE_URLAuth cache URLlocalhost:6379
MF_AUTH_CACHE_PASSAuth cache password""
MF_AUTH_CACHE_DBAuth cache database"0"

Deployment

The service itself is distributed as Docker container. Check the mqtt-adapter service section in docker-compose to see how service is deployed.

To start the service outside of the container, execute the following shell script:

# download the latest version of the service
git clone https://github.com/MainfluxLabs/mainflux

cd mainflux

# compile the mqtt
make mqtt

# copy binary to bin
make install

# set the environment variables and run the service
MF_MQTT_ADAPTER_LOG_LEVEL=[MQTT Adapter Log Level] \
MF_MQTT_ADAPTER_MQTT_PORT=[MQTT adapter MQTT port]
MF_MQTT_ADAPTER_MQTT_TARGET_HOST=[MQTT broker host] \
MF_MQTT_ADAPTER_MQTT_TARGET_PORT=[MQTT broker MQTT port]] \
MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECK=[MQTT health check URL] \
MF_MQTT_ADAPTER_WS_PORT=[MQTT adapter WS port] \
MF_MQTT_ADAPTER_WS_TARGET_HOST=[MQTT broker for MQTT over WS host] \
MF_MQTT_ADAPTER_WS_TARGET_PORT=[MQTT broker for MQTT over WS port]] \
MF_MQTT_ADAPTER_WS_TARGET_PATH=[MQTT adapter WS path] \
MF_MQTT_ADAPTER_FORWARDER_TIMEOUT=[MQTT forwarder for multiprotocol support timeout] \
MF_BROKER_URL=[Message broker instance URL] \
MF_THINGS_AUTH_GRPC_URL=[Things service Auth gRPC URL] \
MF_THINGS_AUTH_GRPC_TIMEOUT=[Things service Auth gRPC request timeout in seconds] \
MF_JAEGER_URL=[Jaeger service URL] \
MF_MQTT_ADAPTER_CLIENT_TLS=[gRPC client TLS] \
MF_MQTT_ADAPTER_CA_CERTS=[CA certs for gRPC client] \
MF_MQTT_ADAPTER_INSTANCE=[Instance for event sourcing] \
MF_MQTT_ADAPTER_ES_URL=[Event sourcing URL] \
MF_MQTT_ADAPTER_ES_PASS=[Event sourcing pass] \
MF_MQTT_ADAPTER_ES_DB=[Event sourcing database] \
MF_AUTH_CACHE_URL=[Auth cache URL] \
MF_AUTH_CACHE_PASS=[Auth cache pass] \
MF_AUTH_CACHE_DB=[Auth cache DB name] \
$GOBIN/mainfluxlabs-mqtt

For more information about service capabilities and its usage, please check out the API documentation API.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
Package redis contains cache implementations using Redis as the underlying database.

# Functions

NewForwarder returns new Forwarder implementation.
NewHandler creates new Handler entity.
NewMqttService instantiates the MQTT service implementation.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Page represents page metadata with content.
PageMetadata contains page metadata that helps navigation.
Subscription represents a user Subscription.

# Interfaces

Forwarder specifies MQTT forwarder interface API.
No description provided by the author
Service specifies an API that must be fullfiled by the domain service implementation, and all of its decorators (e.g.