Hyperledger结构:向对等方发送建议时超时



我在使用结构网关java时遇到了结构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);
} 

链接:https://github.com/hyperledger/fabric-sdk-java/blob/master/src/main/java/org/hyperledger/fabric/sdk/Channel.java

对于";fabric sdk java";你可以这样做:

您可以增加您的设置ProposalWaitTime。

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

链接:https://javadoc.io/static/org.hyperledger.fabric-sdk-java/fabric-sdk-java/2.2.0/org/hyperledger/fabric/sdk/TransactionRequest.html#setProposalWaitTime-长

所以你的代码可能看起来像这样:

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-如果事务已成功提交给订购者,但在从对等方收到提交事件之前超时。

链接:https://hyperledger.github.io/fabric-gateway-java/master/org/hyperledger/fabric/gateway/Contract.html#createTransaction-java.lang.String-

因此,您可以增加setCommitTimeout。

setCommitTimeout-设置在向订购者提交事务后等待接收提交事件的最大时间长度。

事务setCommitTimeout(长超时,时间单位时间单位(

参数:

timeout-等待的最长时间。

timeUnit—超时参数的时间单位。

退货:此事务对象以允许方法链接。

链接:https://hyperledger.github.io/fabric-gateway-java/master/org/hyperledger/fabric/gateway/Transaction.html

最新更新