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')
}
本文来自博客园,作者:HumorChen99,转载请注明原文链接:https://www.cnblogs.com/HumorChen/p/18039693