如何解决Hyperledger Fabric:向对等方发送建议时超时
在使用fabric-gateway-java时,fabric 1.4出现问题。有时,在向对等方发送建议时会引发TimeoutException。在大多数情况下,它运行良好。有人可以帮忙吗?谢谢! 这是错误日志。
2020-09-03 10:02:34,202 [ERROR]--org.hyperledger.fabric.sdk.Channel 4451 -- Channel
Channel{id:1,name: mychannel} sending proposal with transaction
e1d7313d8f8fc09fbae9a3ac2027bbf33ba3714c028a609f26380a4b0810466e to
Peer{ id: 6,name: peer1.org1.example.com,channelName: mychannel,url:grpcs://192.168.1.1:7051,mspid: Org1MSP} failed because of
timeout(35000 milliseconds) expiration
java.util.concurrent.TimeoutException: null
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:432)
at org.hyperledger.fabric.sdk.Channel.sendProposalToPeers(Channel.java:4434)
at org.hyperledger.fabric.sdk.Channel.sendProposal(Channel.java:4358)
at org.hyperledger.fabric.sdk.Channel.sendTransactionProposal(Channel.java:3908)
解决方法
实际上,我没有直接解决您的问题的方法,但我会尽力帮助您。
问题发生在“ fabric-sdk-java”而不是“ fabric-gateway-java”中。 更具体地说:
catch (TimeoutException e) {
message = format("Channel %s sending proposal with transaction %s to %s failed because of timeout(%d milliseconds) expiration",toString(),txID,peerName,transactionContext.getProposalWaitTime());
logger.error(message,e);
}
对于“ fabric-sdk-java”,您可以按照以下步骤操作:
您可以增加setProposalWaitTime。
setProposalWaitTime
public void setProposalWaitTime(long proposalWaitTime)
Sets the timeout for a single proposal request to endorser in milliseconds.
Parameters:
proposalWaitTime - the timeout for a single proposal request to endorser in milliseconds
所以您的代码可能看起来像这样:
TransactionProposalRequest request = fabClient.getInstance().newTransactionProposalRequest();
ChaincodeID ccid = ChaincodeID.newBuilder().setName(Config.CHAINCODE_1_NAME).build();
request.setChaincodeID(ccid);
request.setFcn("createCar");
String[] arguments = { "CAR1","Chevy","Volt","Red","Nick" };
request.setArgs(arguments);
request.setProposalWaitTime(4000);
对于“ fabric-gateway-java”,您可以按照以下步骤操作:
TimeoutException-如果事务已成功提交给订购者,但在收到来自对等方的提交事件之前超时。
因此您可以增加setCommitTimeout。
setCommitTimeout-设置将事务提交给订购者后等待接收提交事件的最长时间。
交易setCommitTimeout(长时间超时, TimeUnit timeUnit)
参数:
超时-等待的最长时间。
timeUnit-超时参数的时间单位。
返回: 该事务对象允许方法链接。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。