Node.js Nodejs WebSocket响应已加密或不可读(连接到exchange套接字)

Node.js Nodejs WebSocket响应已加密或不可读(连接到exchange套接字),node.js,encryption,websocket,socket.io,decode,Node.js,Encryption,Websocket,Socket.io,Decode,我试图向加密交易所的WebSocket发出请求,以获取实时市场数据进行分析。 在浏览器中,数据以可读文本显示,因为它用于填充订单簿。 当我试图通过nodejs连接到它时,我得到了一个十六进制代码,转换后仍然没有意义 const WebSocket = require('ws'); const sendData = '{"method":"deals.subscribe","params":["ETHBTC"

我试图向加密交易所的WebSocket发出请求,以获取实时市场数据进行分析。 在浏览器中,数据以可读文本显示,因为它用于填充订单簿。 当我试图通过nodejs连接到它时,我得到了一个十六进制代码,转换后仍然没有意义

 const WebSocket = require('ws');

    const sendData = '{"method":"deals.subscribe","params":["ETHBTC"],"id":18}'
    
    // Establish a WebSocket connection to the echo server
    const ws = new WebSocket('wss://ws.exchnageAddres.com');
   
    ws.addEventListener('open', () => {

      console.log('Sending:', sendData);
      // Send message to the WebSocket server
      ws.send(sendData);

    });
    
    ws.addEventListener('message', event => {
      
      console.log('Received:', event.data);
    });
答复:

Received: <Buffer 1f 8b 08 00 00 00 00 00 00 03 ab 56 4a 2d 2a ca 2f 52 b2 52 c8 2b cd c9 d1 51 50 2a 4a 2d 2e cd 29 01 f2 ab 95 8a 4b 12 4b 4a 8b 81 4c a5 e2 d2 e4 e4 ... 23 more bytes>
Received: <Buffer 1f 8b 08 00 00 00 00 00 00 03 9d 9a df 8a 5c 47 0e c6 5f 25 cc 75 28 24 95 a4 52 ed 65 96 85 7d 80 dc 85 5c 78 d7 86 35 d8 89 89 ed 8b 10 f2 ee fb 95 ... 2012 more bytes>
Received: <Buffer 1f 8b 08 00 00 00 00 00 00 03 55 8c b1 0a 83 30 14 45 7f 45 de 5c 42 e2 6b 92 da d1 52 e8 07 b8 89 43 da 04 2a 18 0d 26 19 44 fc f7 e6 15 3a 74 3d f7 ... 106 more bytes>
已收到:
收到:
收到:
如何连接到ws-in节点? 我必须使用证书或其他东西吗?如果有人能帮我,那就太棒了

在chrome扩展上测试连接会给我一个Blob对象,但我无法将其转换为数组

使用打嗝解码器工作,但只有在那里


谢谢并致以最诚挚的问候。

1f 8b
是gzip Compression,我怎样才能打开它?我试过zlib。也许你有什么想法?通常,
ws
客户端会帮你做。检查带有
permessage deflate
Sec WebSocket Extensions
标题的请求/响应。否则,他们将在协议之上进行压缩。谢谢你帮了我!:)<代码>1f 8b是gzip压缩吗?我如何才能将其解压缩?我试过zlib。也许你有什么想法?通常,
ws
客户端会帮你做。检查带有
permessage deflate
Sec WebSocket Extensions
标题的请求/响应。否则,他们将在协议之上进行压缩。谢谢你帮了我!:)