如何解决Nodejs WebSocket响应已加密或不可读连接到交换套接字
我正在尝试向加密货币交易所的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? 我是否必须使用证书或其他任何东西?如果有人可以在这里帮助我,那将会很棒。
在chrome扩展程序上测试连接为我提供了一个Blob对象,但我无法真正将其转换为数组。
使用Burp解码器有效,但仅在那儿可用。
感谢和问候。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。