How can I unzip a gz stream in Node.js? I am trying to parse a gz stream (a data file ) using MQTT. My code looks like
var mqtt = require('mqtt')
, client = mqtt.createClient('1883','mqttserver');
client.subscribe('MQTT/#');
client.on('message', function(topic,message) {
var zlib = require('zlib');
zlib.gunzip(message, function(err,message ) {
if (!err) {
console.log(message.toString());
}
});
Why is that whenever I receive a gz stream the data size is ~200 bytes smaller than the sent gz stream?
The issue is with the library itself. The default encoding is set to string 'utf-8' hence the some data is missed. Please take a look at this https://github.com/adamvr/MQTT.js/issues/109
Thanks for all you quick responses
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.