something wrong with node to connect api

我使用nodejs通过设置httpsAgent使用spot连接后请求消息可以得到正常返回值,但使用同一个httpsAgent(直接写到APIBase里)通过websocket连接就会报-60 connect ETIMEDOUT 199.16.158.190:443,后面报-54 read ECONNRESET,有什么好的解决方法吗

有具体的代码示例来看看?

我把APIBase.js里面的httpsAgent修改为自己的SocksProxyAgent,

然后使用下面的代码能够获取到结果

const client = new Spot()
    
    client.tickerPrice('BTCUSDT')
      .then(response => client.logger.log(response.data))
      .catch(error => client.logger.error(error.message))

但同样的用信息用websocket就会报-60

const callbacks = {
  open: (client) => {
    logger.debug('Connected with Websocket server')
    client.tickerPrice({ symbol: 'BTCUSDT' })
  },
  close: () => logger.debug('Disconnected with Websocket server'),
  message: data => logger.info(data)
}

const websocketAPIClient = new WebsocketAPI(null, null, { logger, callbacks })

// disconnect after 20 seconds
setTimeout(() => websocketAPIClient.disconnect(), 20000)

That’s a network error. If it happens every time, you need to check what’s wrong with your network. If it happens sometimes but usually works, then just handle this when it happens and trigger a reconnection mechanism.