mqtt-to-blob

The following guide describes how to catch data from the MQTT-Broker and push them to the MIN.io blob storage

This microservice is still in development and is not considered stable for production use.

MQTT-to-Blob has the function of subscribing to MQTT topics and storing the information into a MIN.io blob storage. The current iteration of MQTT-to-Blob can subscribe to cameraconnect’s MQTT topic and send the image data to MIN.io server’s bucket.

The input format of mqtt-to-blob is in accordance with /productImage JSON format. The information from the JSON is extracted and then stored into an image file in MIN.io with the metadata attached.

Before running the code, the environment variables have to be adjusted for the system. Information regarding the environment variables can be seen in the respective section.

Dependencies

  • paho-mqtt==1.6.1
  • numpy==1.21.3
  • minio==7.1.1

Environment variables

This chapter explains all used environment variables.

VariableTypeDescriptionPossible valuesExample value
BROKER_URLstrSpecifies the address to connect to the MQTT-Brokerall DNS names or IP address127.0.0.1
BROKER_PORTintSpecifies the port for the MQTT-Brokervalid port number1883
TOPICstrMQTT Topic namePublished MQTT Topic nameia/rawImage/#
MINIO_URLstrSpecifies the database DNS name / IP-address for the MIN.io serverall DNS names or IP address with its port numberplay.min.io
MINIO_SECUREboolSelect True or False to activate HTTPS connection or notTrue or FalseTrue
MINIO_ACCESS_KEYstrSpecifies the username for MIN.io servereligible usernameusername
MINIO_SECRET_KEYstrSpecifies the password for MIN.io serverpassword of the userpassword
BUCKET_NAMEstrSpecifies the Bucket name to store the blob in MIN.io serverBucket nameBucket-name
LOGGING_LEVELstrSelect level for logging messagesDEBUG INFO ERROR WARNING CRITICALDEBUG

MQTT Connection Return Code

Return CodeMeaning
0Successful Connection
1Connection refused - incorrect protocol version
2Connection refused - invalid client identifier
3Connection refused - server unavailable
4Connection refused - Bad username or password
5Connection refused - not authorised
6-255Currently unused

Future work

  • In the future, MQTT-to-Blob should also be able to store different kind of data such as sound and video