如何解决纹波测试服务器连接错误?

问题描述 投票:0回答:1

我在使用RippleAPI for Java连接到测试服务器时始终遇到以下错误:

[ConnectionError(Error: connect() timed out after 2000 ms. If your internet connection is working, the rippled server may be blocked or inaccessible.)]

但是,如果我尝试从卷曲中获得平衡,它会起作用:

curl 'https://testnet.data.api.ripple.com/v2/accounts/rwAVpkGNU9Shn63EpFq7ju1tr89SsSBwHz/balances?currency=XRP'

下面的代码段:

'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;

const api = new RippleAPI({
  server: 'wss://s.altnet.rippletest.net:51233' // Public rippled server
});
api.connect().then(() => {
  /* begin custom code ------------------------------------ */
  const myAddress = 'rwAVpkGNU9Shn63EpFq7ju1tr89SsSBwHz';

  console.log('getting account info for', myAddress);
  return api.getAccountInfo(myAddress);

}).then(info => {
  console.log(info);
  console.log('getAccountInfo done');

  /* end custom code -------------------------------------- */
}).then(() => {
  return api.disconnect();
}).then(() => {
  console.log('done and disconnected.');
}).catch(console.error);
javascript ripple cryptocurrency
1个回答
0
投票
用途:api.connection._config.connectionTimeout = 3e4;
© www.soinside.com 2019 - 2024. All rights reserved.