Mqtt payload , Gzip format

Hi, i connected to broker and get all topic in Mqtt Engine . all payload in Gzip format. what's the best approach to consume it as Tags in Ignition. didn't work before with gZip

Ewww! They're all stringified, which corrupts the gzip encoding. If you can grab uncorrupted byte arrays, you can script the decode with Java's GZIPInputStream.

1 Like

Failed to decode after getting data through MQTT engine.
One of my colleagues read data direct from broker bypass ignition and able to convert it to JSON
Need more dive in MQTT engine

What's the device publishing this data? Is there an option to turn it off? Is it supposed to be Sparkplug but not compliant?

we can't turned off.. it ASRS system.. there's other system consume these data direct from broker using GO library and working fine .. my concern if the Engine did any type of decoding or reformat -

This how it work ..
Create Custom Namespace with Encoding Charset as iso8859_1 which gave me flexibility to read raw data GZIP as binary .. now . i have more than 2000 Tags .. what's the best approach to handle these no. of tags .

import gzip
import json
import StringIO
tagPaths = ['[MQTT Engine]telemetry/XY']

# Read the MQTT payload as raw bytes (gZIP compressed)
mqttValue = system.tag.readBlocking(tagPaths)[0].value
byte_data = mqttValue.encode('iso8859_1')


# Try decoding the data as base64
try:
    # Use StringIO to handle the GZIP byte data stream
    compressed_data = StringIO.StringIO(byte_data)
    decompressed_data = gzip.GzipFile(fileobj=compressed_data).read()
    
    # Now decompressed_data holds the original data
    print("Data:", decompressed_data)

except Exception as e:
    print("Error :", e)