websocket stream issue

node v12.14.0
version: 1.0.0
const WebSocket = require('ws') const ws = new WebSocket('wss://api-pub.bitfinex.com/ws/2') const messageStream = WebSocket.createWebSocketStream(ws, { encoding: 'utf8' }) ws.once('open', function open() { ws.send(JSON.stringify({ event: 'subscribe', channel: 'book', len: 100, prec: 'P0', freq: 'F0', symbol: `tBTCUSD` })) }) async function run() { for await (let message of messageStream) { console.log('string msg', message) console.log('parsed msg', JSON.parse(message)) } } await run()

no comments

    sign in to comment