我尝试使用下面的代码来连接ws,但是我无法成功的连接,这是为什么?
import dotenv from 'dotenv';
import { WebsocketAPI, WsMarketTypes } from '@binance/connector-typescript';
dotenv.config();
const options: WsMarketTypes.pingOptions = {
id: 8798
};
const callbacks = {
open: (client: WebsocketAPI) => {
console.debug('Connected to WebSocket server');
client.ping(options);
},
close: () => console.debug('Disconnected from WebSocket server'),
message: (data: string) => {
const parseData = JSON.parse(data);
console.info(parseData);
}
};
const websocketAPIClient = new WebsocketAPI(process.env.AK, process.env.SK, { callbacks });
setTimeout(() => websocketAPIClient.disconnect(), 10000);