NodeJS Websocket解密被GZIP压缩过的二进制数据

  • 解密前消息
    在这里插入图片描述
  • 解密后:
    {“status”:“error”,“ts”:1605926619229,“id”:“”,“err-code”:“bad-request”,“err-msg”:“1, is not json string”}
  • 依赖
  • websocket
  • zlib
  • 解密函数
let decode=function(websocket_msg){
        return Buffer.from(zlib.gunzipSync(websocket_msg.binaryData),'binary').toString('utf-8')
    }
posted @ 2020-11-21 10:45  HumorChen99  阅读(1)  评论(0编辑  收藏  举报  来源