【问题标题】:How to fix "Error: No successful events received" when submitting a transaction on Hyperledger fabric?在 Hyperledger Fabric 上提交交易时如何解决“错误:未收到成功事件”?
【发布时间】:2019-04-12 12:19:55
【问题描述】:

我在https://developer.ibm.com/tutorials/ibm-blockchain-platform-vscode-smart-contract/ 学习教程,当我通过 IBM 区块链平台 VS 代码扩展提交交易时,我收到错误:

“提交交易时出错:未收到成功事件”。

调用的函数是“实例化”,如下所示:

    public async instantiate(ctx: Context): Promise<any> {
        const greeting = { text: 'Instantiate was called!' };
        await ctx.stub.putState('GREETING', Buffer.from(JSON.stringify(greeting)));
    }

即使抛出错误,运行它也会成功写入账本。之后我能够查询分类帐并看到正确的值“{ text: 'Instantiate was called!' }" 被返回。

这是我为instantiate 运行单元测试时的错误跟踪。希望对您有所帮助:

     Error: No successful events received
      at AllForTxStrategy.checkCompletion (node_modules/fabric-network/lib/impl/event/allfortxstrategy.js:34:12)
      at AllForTxStrategy.errorReceived (node_modules/fabric-network/lib/impl/event/abstracteventstrategy.js:67:8)
      at TransactionEventHandler._onError (node_modules/fabric-network/lib/impl/event/transactioneventhandler.js:126:17)
      at EventRegistration.eventHub.registerTxEvent [as _onErrorFn] (node_modules/fabric-network/lib/impl/event/transactioneventhandler.js:90:20)
      at EventRegistration.onError (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:1709:9)
      at ChannelEventHub._closeAllCallbacks (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:867:15)
      at ChannelEventHub._disconnect (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:625:8)
      at ClientDuplexStream._stream.on (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:539:11)
      at addChunk (_stream_readable.js:283:12)
      at readableAddChunk (_stream_readable.js:264:11)
      at ClientDuplexStream.Readable.push (_stream_readable.js:219:10)
      at Object.onReceiveMessage (node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:1292:19)
      at InterceptingListener.recvMessageWithContext (node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:607:19)
      at /Users/chana/projects/ibm-bp/node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:706:14

【问题讨论】:

  • 所以看起来链码已实例化并运行了实例化事务。如果您尝试使用 VSCode 调用其他事务,您会遇到同样的问题吗? (您甚至可以再次调用实例化事务。它只是一个可以反复运行的普通事务,并且不仅在您实例化合约时可以调用)
  • 是的。当我为实例化函数重新尝试提交事务时,也会出现同样的问题。其他非常基本的功能也存在同样的问题。为instantiate 选择“评估交易”不会引发错误。虽然这意味着它不会写入分类帐。

标签: hyperledger-fabric ibm-blockchain ibp-vscode-extension


【解决方案1】:

我在提交交易后注意到 VS Code 中的 local fabric 输出存在差异:

[2019 年 4 月 13 日晚上 9:41:22] [信息] fabricvscodelocalfabric_peer0.org1.example.com|2019-04-12 12:17:55.210 UTC [common.deliver] DeliverBlocks -> WARN 05a 拒绝交付 172.19.0.1:34608 由于信封验证错误:信封时间戳 2019-04-13 11:41:22.439 +0000 UTC 距离超过 15m0s 当前服务器时间 2019-04-12 12:17:55.210409997 +0000 UTC m=+169.648611001

这看起来像是 peer0 上的某种时间差异,所以我进入它的 bash 并运行 date 以查看不正确的服务器时间(2019-04-12 12:17:55),然后我开始尝试更正服务器时间。

在此之后,我重新尝试了Submit Transaction,它没有抛出错误!

我试图通过拆除结构然后重新启动来再次复制原始问题,但提交事务现在似乎按预期工作。

【讨论】:

  • 您描述的问题是我认为可能是问题所在。我猜你是在 windows 或 mac 上运行 VSCode 吗?那么问题是用于运行各种容器的虚拟机(这些平台上的 docker 必须有一个用于 linux 容器的虚拟机)与您的主机存在时间差异,这会阻止客户端注册事件。这些事件用于确定 tx 何时提交。如果有效,它不会阻止 tx 被提交。
  • 是的,我在 mac 上运行 VSCode。感谢您澄清@david_k。欣赏它。
  • 您好,我遇到了类似的错误,我想设置对等时间。你是怎么设置的? date 命令导致错误“不允许操作”
  • @SKuri 在这里,我们将从 peer0 获取 UTC 日期,然后使用它在本地计算机上设置 UTC 日期。获取UTC日期以在另一台机器上设置&gt; date -u "+%m%d%H%M%Y"在本地机器上设置UTC日期&gt; date -u 090509112019
猜你喜欢
  • 2023-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多