异步功能停止处理,不能只在生产AWS EC2集群EXC扔
我已经在我下面的代码部署到我的生产现场遇到一个令人费解的错误状态。本地方面,所有这些功能进行了测试和工作。
我试图洞悉承诺它似乎失败了,但他们不旅行的任何异常。该usersApiGateway.getNonce是一个GET请求和我核实,我得到了正确的返回值时,我就派邮差GET请求。
在我的AWS日志,它基本上表明它执行,直到指定点下方,然后就停止。然后,也许在10分钟之后就退出尝试调用通过asyncTimeout进程,那么它是永久卡住。我如何能找到这个根源任何帮助表示赞赏。
违规的功能:
async createBuyOrder(tokenAddress, amountSell, amountBuy) {
amountSell = new BigNumber(amountSell);
amountBuy = new BigNumber(amountBuy);
let nonce = '';
[amountBuy, amountSell, nonce] = await Promise.all([
web3Service.convertToWei(tokenAddress, amountBuy),
web3Service.convertToWei(ETHER_ADDRESS, amountSell),
usersApiGateway.getNonce(this.adminAccount)
]);
// FUNCTION FAILS TO RETURN ANYTHING AFTER THIS POINT
// Console.log for nonce, amount buy/sell/buy order below fail to show up
// that is what I mean by not working
const buyOrder = {
"addressBuy" : tokenAddress,
"amountBuy" : amountBuy,
"addressSell": ETHER_ADDRESS,
"amountSell" : amountSell,
"nonce" : nonce,
}
await this.createOrder(buyOrder);
}
这是从这个函数调用:
async populateOrderBook(tokenAddress, numOrders = 1) {
for(let i = numOrders; i > 0; i--) {
for(let j = -1; j < numOrders - i; j++){
try {
await this.createBuyOrder(tokenAddress, BUYORDER_amountSell, BUYORDER_amountBuy);
await this.createSellOrder(tokenAddress, SELLORDER_amountBuy, SELLORDER_amountSell);
} catch(exc) {
console.log(exc)
}
}
}
}
这是在类的init()函数周期性地调用
asyncTimeout(async () => {
try {
await Promise.all([
this.populateOrderBook(tokenAddress, 3)
]);
} catch (exc) {
console.error('Error while populating order book from Kyber');
console.error(exc);
}
}, 60000);
我测试过,从web3Service它要挂在看似违规的功能,它似乎本地工作就好了
async convertToWei(tokenAddress, amount) {
const numberOfDecimals = await this.tokenDecimals(tokenAddress);
return new BigNumber(toBaseUnit(amount, numberOfDecimals));
}
回答如下:
事实证明,我的节点连接到复仇blockchain没有发挥作用。我使用的连接,以确定我的convertToWei函数调用多少个小数位,而且由于连接中断时,它只是卡在了一个循环,不可能解决。
异步功能停止处理,不能只在生产AWS EC2集群EXC扔
我已经在我下面的代码部署到我的生产现场遇到一个令人费解的错误状态。本地方面,所有这些功能进行了测试和工作。
我试图洞悉承诺它似乎失败了,但他们不旅行的任何异常。该usersApiGateway.getNonce是一个GET请求和我核实,我得到了正确的返回值时,我就派邮差GET请求。
在我的AWS日志,它基本上表明它执行,直到指定点下方,然后就停止。然后,也许在10分钟之后就退出尝试调用通过asyncTimeout进程,那么它是永久卡住。我如何能找到这个根源任何帮助表示赞赏。
违规的功能:
async createBuyOrder(tokenAddress, amountSell, amountBuy) {
amountSell = new BigNumber(amountSell);
amountBuy = new BigNumber(amountBuy);
let nonce = '';
[amountBuy, amountSell, nonce] = await Promise.all([
web3Service.convertToWei(tokenAddress, amountBuy),
web3Service.convertToWei(ETHER_ADDRESS, amountSell),
usersApiGateway.getNonce(this.adminAccount)
]);
// FUNCTION FAILS TO RETURN ANYTHING AFTER THIS POINT
// Console.log for nonce, amount buy/sell/buy order below fail to show up
// that is what I mean by not working
const buyOrder = {
"addressBuy" : tokenAddress,
"amountBuy" : amountBuy,
"addressSell": ETHER_ADDRESS,
"amountSell" : amountSell,
"nonce" : nonce,
}
await this.createOrder(buyOrder);
}
这是从这个函数调用:
async populateOrderBook(tokenAddress, numOrders = 1) {
for(let i = numOrders; i > 0; i--) {
for(let j = -1; j < numOrders - i; j++){
try {
await this.createBuyOrder(tokenAddress, BUYORDER_amountSell, BUYORDER_amountBuy);
await this.createSellOrder(tokenAddress, SELLORDER_amountBuy, SELLORDER_amountSell);
} catch(exc) {
console.log(exc)
}
}
}
}
这是在类的init()函数周期性地调用
asyncTimeout(async () => {
try {
await Promise.all([
this.populateOrderBook(tokenAddress, 3)
]);
} catch (exc) {
console.error('Error while populating order book from Kyber');
console.error(exc);
}
}, 60000);
我测试过,从web3Service它要挂在看似违规的功能,它似乎本地工作就好了
async convertToWei(tokenAddress, amount) {
const numberOfDecimals = await this.tokenDecimals(tokenAddress);
return new BigNumber(toBaseUnit(amount, numberOfDecimals));
}
回答如下:
事实证明,我的节点连接到复仇blockchain没有发挥作用。我使用的连接,以确定我的convertToWei函数调用多少个小数位,而且由于连接中断时,它只是卡在了一个循环,不可能解决。