The data returned by websocket is in gzip format. How to decompress it?

the data returned by websocket is in gzip format. How to decompress it?

function ws (url) {

var ws = new WebSocket(url);
ws.onopen = function(evt){
    console.log(evt);
};
ws.onmessage = function(evt){
    console.log(evt);                
};
ws.onerror = function(evt){
    console.log(evt);
}

}
ws ("wss://api.huobi.br.com/market/tickers");

the printed evt looks like this

clipboard.png

data is a Blob object.
looked up the information on the Internet and said that it can be decompressed by using the pako.inflate () method in pakojs, but I reported an error after using it:
Uncaught unknown compression method
/ / unknown compression method

so I don"t know how to decompress it.

Apr.16,2021

thanks to the idea from upstairs, the data I asked to return is a Blob object that stores binary data.
so you need to extract the data from the Blob object first, and then extract it with the pako.inflate () method

For more information about what a Blob object is, please see link description

.

the specific code is as follows:
ws.onmessage = function (evt) {

if(evt.data instanceof Blob){
    let result = '';
    let reader = new FileReader();
    //FileReader:Blob
    reader.onload = function() {
        result = JSON.parse(pako.inflate(reader.result,{to:'string'}));
       //pako.inflate()json
        if(result.ping){
            ws.send(JSON.stringify({pong:result.ping}));
            //
         }
     }
     reader.readAsBinaryString(evt.data);
     //
 }

};


this is not gzip, so there is no decompression.

can be used in this way


var reader = new FileReader();
reader.onload = function() {
    alert(reader.result);
}
reader.readAsText(evt);


Thank you, I also met

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cd3d-2c33a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cd3d-2c33a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?