mirror of
https://github.com/mainflux/mainflux.git
synced 2024-11-20 22:42:14 +08:00
5834d364ad
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> |
||
---|---|---|
.. | ||
src | ||
.gitignore | ||
Dockerfile | ||
README.md | ||
rebar3 | ||
rebar.config |
MQTT adapter
MQTT adapter provides an MQTT API for sending and receiving messages through the platform.
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.
Variable | Description | Default |
---|---|---|
MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
MF_THINGS_AUTH_GRPC_URL | Things service gRPC URL for Auth | tcp://localhost:8183 |
MF_MQTT_ADAPTER_ES_URL | Redis ES URL | http://localhost:6379 |
MF_MQTT_VERNEMQ_GRPC_POOL_SIZE | Number of processes to do gRPC comm | 10 |
Apart from this, VerneMQ configuration found here can be customized.
When run in the Docker,
DOCKER_VERNEMQ_PLUGINS__VMQ_PASSWD: "off"
DOCKER_VERNEMQ_PLUGINS__VMQ_ACL: "off"
DOCKER_VERNEMQ_PLUGINS__MFX_AUTH: "on"
DOCKER_VERNEMQ_PLUGINS__MFX_AUTH__PATH: /mainflux/_build/default
DOCKER_VERNEMQ_LISTENER__WS__DEFAULT: "127.0.0.1:8880"
N.B. in this Docker env var setup,
__
replaces.
in the config file, soplugins.mfx_auth.path
becomesDOCKER_VERNEMQ_PLUGINS__MFX_AUTH__PATH
Deployment
Docker
The service is distributed as Docker container. The following snippet provides a compose file template that can be used to deploy the service container locally:
version: "2"
services:
mqtt-adapter:
image: mainflux/mqtt:latest
container_name: mainflux-mqtt
depends_on:
- things
- nats
- mqtt-redis
restart: on-failure
environment:
MF_MQTT_ADAPTER_LOG_LEVEL: ${MF_MQTT_ADAPTER_LOG_LEVEL}
MF_MQTT_INSTANCE_ID: mqtt-adapter
MF_MQTT_ADAPTER_PORT: ${MF_MQTT_ADAPTER_PORT}
MF_MQTT_ADAPTER_WS_PORT: ${MF_MQTT_ADAPTER_WS_PORT}
MF_MQTT_ADAPTER_REDIS_URL: tcp://mqtt-redis:${MF_REDIS_TCP_PORT}
MF_MQTT_ADAPTER_ES_URL: tcp://es-redis:${MF_REDIS_TCP_PORT}
MF_NATS_URL: ${MF_NATS_URL}
MF_THINGS_AUTH_HTTP_URL: http://things:${MF_THINGS_AUTH_HTTP_PORT}
DOCKER_VERNEMQ_PLUGINS__VMQ_PASSWD: "off"
DOCKER_VERNEMQ_PLUGINS__VMQ_ACL: "off"
DOCKER_VERNEMQ_PLUGINS__MFX_AUTH: "on"
DOCKER_VERNEMQ_PLUGINS__MFX_AUTH__PATH: /mainflux/_build/default
DOCKER_VERNEMQ_LISTENER__WS__DEFAULT: "127.0.0.1:8880"
ports:
- ${MF_MQTT_ADAPTER_PORT}:${MF_MQTT_ADAPTER_PORT}
- ${MF_MQTT_ADAPTER_WS_PORT}:${MF_MQTT_ADAPTER_WS_PORT}
networks:
- mainflux-base-net
Native
Generate protobuf files
mkdir -p src/protos
rebar3 grpc gen
Compile
./rebar3 compile
Load Plugin
First start VerneMQ broker:
cd $VERNEMQ_BROKER_PATH
./_build/default/rel/vernemq/bin/vernemq start
Remove other plugins:
cd $VERNEMQ_BROKER_PATH
./_build/default/rel/vernemq/bin/vmq-admin plugin disable -n vmq_passwd
./_build/default/rel/vernemq/bin/vmq-admin plugin disable -n vmq_acl
Enable Mainflux mfx_auth
plugin:
cd $VERNEMQ_BROKER_PATH
./_build/default/rel/vernemq/bin/vmq-admin plugin enable -n mfx_auth -p <path_to_mfx_auth_plugin>/_build/default
Debugging
Inspect logs:
cd $VERNEMQ_BROKER_PATH
cat _build/default/rel/vernemq/log/console.log
cat _build/default/rel/vernemq/log/error.log