NOISSUE - Update aedes version and fix Dockerfile (#863)

* Update MQTT adapter and add message TTL

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Fix clean command

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
This commit is contained in:
Aleksandar Novaković 2019-09-17 20:25:38 +02:00 committed by Drasko DRASKOVIC
parent d20dfa84bc
commit 08105205e1
8 changed files with 3618 additions and 8 deletions

View File

@ -36,7 +36,7 @@ all: $(SERVICES) mqtt
clean:
rm -rf ${BUILD_DIR}
rm -rf mqtt/node_modules
rm -rf mqtt/aedes/node_modules
cleandocker:
# Stop all containers (if running)

View File

@ -1,3 +1,3 @@
.git
node_modules
node_modules/
test

View File

@ -1 +1 @@
node_modules
node_modules/

View File

@ -10,7 +10,7 @@ RUN npm rebuild && npm install --only=production
FROM node:10.15.1-alpine
## Copy built node modules and binaries without including the toolchain
COPY --from=builder node_modules .
COPY --from=builder node_modules/ ./node_modules
COPY *.proto mqtt/* ./
EXPOSE 1883 8880

View File

@ -20,6 +20,7 @@ default values.
| MF_MQTT_ADAPTER_REDIS_HOST | Redis host | localhost |
| MF_MQTT_ADAPTER_REDIS_PASS | Redis pass | mqtt |
| MF_MQTT_ADAPTER_REDIS_DB | Redis db | 0 |
| MF_MQTT_ADAPTER_MESSAGE_TTL | MQTT message TTL in seconds in Redis | 60 |
| MF_MQTT_ADAPTER_ES_PORT | Event stream port | 6379 |
| MF_MQTT_ADAPTER_ES_HOST | Event stream host | localhost |
| MF_MQTT_ADAPTER_ES_PASS | Event stream pass | mqtt |
@ -53,6 +54,7 @@ services:
MF_MQTT_ADAPTER_REDIS_HOST: [Redis host]
MF_MQTT_ADAPTER_REDIS_PASS: [Redis pass]
MF_MQTT_ADAPTER_REDIS_DB: [Redis db]
MF_MQTT_ADAPTER_MESSAGE_TTL: [MQTT message TTL in seconds in Redis]
MF_MQTT_ADAPTER_ES_PORT: [Event stream port]
MF_MQTT_ADAPTER_ES_HOST: [Event stream host]
MF_MQTT_ADAPTER_ES_PASS: [Event stream pass]
@ -74,7 +76,7 @@ cd $GOPATH/src/github.com/mainflux/mainflux/mqtt
npm install
# set the environment variables and run the service
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_MQTT_ADAPTER_LOG_LEVEL=[MQTT adapter log level] MF_MQTT_INSTANCE_ID=[ID of MQTT adapter instance] MF_MQTT_ADAPTER_PORT=[Service MQTT port] MF_MQTT_ADAPTER_WS_PORT=[Service WS port] MF_MQTT_ADAPTER_REDIS_PORT=[Redis port] MF_MQTT_ADAPTER_REDIS_HOST=[Redis host] MF_MQTT_ADAPTER_REDIS_PASS=[Redis pass] MF_MQTT_ADAPTER_REDIS_DB=[Redis db] MF_MQTT_ADAPTER_ES_PORT=[Event stream port] MF_MQTT_ADAPTER_ES_HOST=[Event stream host] MF_MQTT_ADAPTER_ES_PASS=[Event stream pass] MF_MQTT_ADAPTER_ES_DB=[Event stream db] MF_MQTT_CONCURRENT_MESSAGES=[Number of messages that can be concurrently exchanged] MF_MQTT_ADAPTER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_MQTT_ADAPTER_CA_CERTS=[Path to trusted CAs in PEM format] node mqtt.js ..
MF_THINGS_URL=[Things service URL] MF_NATS_URL=[NATS instance URL] MF_MQTT_ADAPTER_LOG_LEVEL=[MQTT adapter log level] MF_MQTT_INSTANCE_ID=[ID of MQTT adapter instance] MF_MQTT_ADAPTER_PORT=[Service MQTT port] MF_MQTT_ADAPTER_WS_PORT=[Service WS port] MF_MQTT_ADAPTER_REDIS_PORT=[Redis port] MF_MQTT_ADAPTER_REDIS_HOST=[Redis host] MF_MQTT_ADAPTER_REDIS_PASS=[Redis pass] MF_MQTT_ADAPTER_REDIS_DB=[Redis db] MF_MQTT_ADAPTER_MESSAGE_TTL=[MQTT message TTL in seconds in Redis] MF_MQTT_ADAPTER_ES_PORT=[Event stream port] MF_MQTT_ADAPTER_ES_HOST=[Event stream host] MF_MQTT_ADAPTER_ES_PASS=[Event stream pass] MF_MQTT_ADAPTER_ES_DB=[Event stream db] MF_MQTT_CONCURRENT_MESSAGES=[Number of messages that can be concurrently exchanged] MF_MQTT_ADAPTER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] MF_MQTT_ADAPTER_CA_CERTS=[Path to trusted CAs in PEM format] node mqtt.js ..
```
## Usage

View File

@ -30,6 +30,7 @@ var config = {
redis_host: process.env.MF_MQTT_ADAPTER_REDIS_HOST || 'localhost',
redis_pass: process.env.MF_MQTT_ADAPTER_REDIS_PASS || 'mqtt',
redis_db: Number(process.env.MF_MQTT_ADAPTER_REDIS_DB) || 0,
message_ttl: Number(process.env.MF_MQTT_ADAPTER_MESSAGE_TTL) || 60, // in seconds
es_port: Number(process.env.MF_MQTT_ADAPTER_ES_PORT) || 6379,
es_host: process.env.MF_MQTT_ADAPTER_ES_HOST || 'localhost',
es_pass: process.env.MF_MQTT_ADAPTER_ES_PASS || 'mqtt',
@ -63,7 +64,10 @@ var config = {
port: config.redis_port,
host: config.redis_host,
password: config.redis_pass,
db: config.redis_db
db: config.redis_db,
packetTTL: function (packet) {
return config.message_ttl; // in seconds
}
}),
mqRedis = require('mqemitter-redis')({
port: config.redis_port,
@ -72,6 +76,7 @@ var config = {
db: config.redis_db
}),
aedes = require('aedes')({
id: config.instance_id ? config.instance_id : undefined,
mq: mqRedis,
persistence: aedesRedis,
concurrency: config.concurrency

3603
mqtt/aedes/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,9 +15,9 @@
"dependencies": {
"2": "^1.0.2",
"@grpc/proto-loader": "^0.5.0",
"aedes": "^0.38.0",
"aedes": "^0.39.0",
"aedes-logging": "^2.0.1",
"aedes-persistence-redis": "^5.1.0",
"aedes-persistence-redis": "^6.0.0",
"atob": "^2.0.3",
"bunyan": "^1.5.1",
"grpc": "^1.20.3",