4

I GZip some JSON data on server, send it via Engine.IO implementation of Web Sockets

function sendResourceDataToObserver(socket, data) {
  zlib.gzip(data, function (_, result) {
    socket.send(result);
  });
}

and decompress it with ZLIB module that I import with Browserify (http://browserify.org/)

socket.on('message', function (data) {
        zlib.gunzip(data, function(err, decoded) {
          if (err) {
            console.error(err);
          }
          console.log(decoded);
        });
});

However I get this error ('decoded' is obviously undefined):

Error: invalid file signature:,�
    at Error (<anonymous>)
    at nb.i (http://localhost:5000/bundle.js:1994:184)
    at Bb (http://localhost:5000/bundle.js:2000:424)
    at http://localhost:5000/bundle.js:2000:338
    at http://localhost:5000/bundle.js:1869:21 

Any ideas?

Deniz Ozger
  • 2,565
  • 23
  • 27

0 Answers0