sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT, Hyperledger Fabric(balance-transfer example)

sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT, Hyperledger Fabric(balance-transfer example)

当我从 Postman 向我的 ubuntu 服务器进行查询或调用时,我遇到错误,显示 sendProposal - timed out after:45000sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT。我正在调整,但无法弄清楚问题是什么。我正在使用 balance-transfer example。 运行 个容器如下:

    CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
    f07e92dcdf7e        my_node/node-app             "npm start"              33 minutes ago      Up 33 minutes       0.0.0.0:9999->4000/tcp                           my_node
    f8b84ebc7510        hyperledger/fabric-peer      "peer node start"        33 minutes ago      Up 33 minutes       0.0.0.0:7056->7051/tcp, 0.0.0.0:7058->7053/tcp   peer1.org1.example.com
    301407e3285b        hyperledger/fabric-peer      "peer node start"        33 minutes ago      Up 33 minutes       0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp   peer0.org2.example.com
    09ef3c426af2        hyperledger/fabric-peer      "peer node start"        33 minutes ago      Up 33 minutes       0.0.0.0:8056->7051/tcp, 0.0.0.0:8058->7053/tcp   peer1.org2.example.com
    d46778455d1a        hyperledger/fabric-peer      "peer node start"        33 minutes ago      Up 33 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
    1e14126d1920        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   33 minutes ago      Up 33 minutes       0.0.0.0:7054->7054/tcp                           ca_peerOrg1
    5bd780de76a9        hyperledger/fabric-ca        "sh -c 'fabric-ca-..."   33 minutes ago      Up 33 minutes       0.0.0.0:8054->7054/tcp                           ca_peerOrg2
    beafd29107fa        hyperledger/fabric-orderer   "orderer"                33 minutes ago      Up 33 minutes       0.0.0.0:7050->7050/tcp                           orderer.example.com


Full error log:

[2017-09-29 03:11:22.270] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: 8afc8e33226a0f3a364ceb4c4826d3c442f26d92dda33fd7ff12027e214e354f>,
  s: <BN: 1d7ff1d66ae71f27571b5d90e95f18fbcc1c52ee8954ae03c330f22c5206333b>,
  recoveryParam: 0 }
error: [Peer.js]: sendProposal - timed out after:45000
error: [Peer.js]: sendProposal - timed out after:45000
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/usr/src/app/node_modules/fabric-client/lib/Peer.js:107:19)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/usr/src/app/node_modules/fabric-client/lib/Peer.js:107:19)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

第一个容器 node.js API 暴露在端口 4000 上,然后 docker 化并与端口 9999 桥接。

我读到有一个 bug 但它已在 Hyperledger v1.0.1 上解决。我怎么知道我使用的是什么版本,v1.0.0 还是 v1.0.1? P.S。我的 Docker 版本 17.09.0-ce; docker-撰写版本 1.11.2。节点:硼。 network-config.json ca ip address(org1, org2): 我的 Ubuntu 服务器 ip 其他 ips,如 Orderer 和 peers(请求、事件):localhost

如有任何建议,我们将不胜感激。谢谢!

更新

按照 Gari 的建议,我通过将 localhost 替换为服务名称来更改 network-config.json 文件。它看起来像这样:

        "network-config": {
                "orderer": {
                        "url": "grpcs://orderer.example.com:7050",
                        "server-hostname": "orderer.example.com",
                        "tls_cacerts": "../artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers$
                },
                "org1": {
                        "name": "peerOrg1",
                        "mspid": "Org1MSP",
                        "ca": "https://ca.org1.example.com:7054",
                        "peers": {
                                "peer1": {
                                        "requests": "grpcs://peer0.org1.example.com:7051",
                                        "events": "grpcs://peer0.org1.example.com:7053",
                                        "server-hostname": "peer0.org1.example.com",
                                        "tls_cacerts": "../artifacts/channel/crypto-config/peerOrganizations/org1.ex$
                                },
                                "peer2": {
                                        "requests": "grpcs://peer1.org1.example.com:7056",
                                        "events": "grpcs://peer1.org1.example.com:7058",
                                        "server-hostname": "peer1.org1.example.com",
                                        "tls_cacerts": "../artifacts/channel/crypto-config/peerOrganizations/org1.ex$
                                }
                        },
                        "admin": {
                                "key": "../artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/$
                                "cert": "../artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users$
                        }
                },
                "org2": {
                        "name": "peerOrg2",
                        "mspid": "Org2MSP",
                        "ca": "https://ca.org1.example.com:8054",
                        "peers": {
                                "peer1": {
                                        "requests": "grpcs://peer0.org2.example.com:8051",
                                        "events": "grpcs://peer0.org2.example.com:8053",
                                        "server-hostname": "peer0.org2.example.com",
                                        "tls_cacerts": "../artifacts/channel/crypto-config/peerOrganizations/org2.ex$
                                },
                                "peer2": {
                                        "requests": "grpcs://peer1.org2.example.com:8056",
                                        "events": "grpcs://peer1.org2.example.com:8058",
                                        "server-hostname": "peer1.org2.example.com",
                                        "tls_cacerts": "../artifacts/channel/crypto-config/peerOrganizations/org2.ex$
                                }
                        },
                        "admin": {
                                "key": "../artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users/$
                                "cert": "../artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users$
                        }
                }
        }
}

现在我可以进行前两次 API 调用,它们是成功的:

第三次调用时出错加入频道请求 - sendPeersProposal - Promise is rejected: Error: Connect Failed

以前日志的完整错误消息:

[2017-09-30 06:30:04.753] [INFO] Join-Channel - received member object for admin of the organization "org1":
[2017-09-30 06:30:04.763] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: 14e9fb6acf44b2d9d96d5888935085bb45a2363fc3171992e73cba41c612ec93>,
  s: <BN: 1c800803823a185d0ed5a55f3a786bda1fc51827a0a296fbe432180d1e5165df>,
  recoveryParam: 1 }
info: [EventHub.js]: _connect - options {"grpc.ssl_target_name_override":"peer0.org1.example.com","grpc.default_authority":"peer0.org1.example.com"}
[2017-09-30 06:30:04.807] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: e1cdeef11d37de28810bed04d525abf4ed4959899f64e7129483110b07d9ef50>,
  s: <BN: 65720ba0dfcdb959cce0a3d69b016097c7895aab1891172ded659aece90d467e>,
  recoveryParam: 1 }
info: [EventHub.js]: _connect - options {"grpc.ssl_target_name_override":"peer1.org1.example.com","grpc.default_authority":"peer1.org1.example.com"}
[2017-09-30 06:30:04.814] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: e1cdeef11d37de28810bed04d525abf4ed4959899f64e7129483110b07d9ef50>,
  s: <BN: 65720ba0dfcdb959cce0a3d69b016097c7895aab1891172ded659aece90d467e>,
  recoveryParam: 1 }
[2017-09-30 06:30:04.823] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: ac5da50d7afa8c20be3c0833f7d034761eba2f5f3051abb90c095106be273e1d>,
  s: <BN: 6815f1b1ce217faf6827521351e401f3f0accce9748ddc999de7649657024f21>,
  recoveryParam: 1 }
[2017-09-30 06:30:04.835] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature:  Signature {
  r: <BN: ab6a1ea9d36c8cabc53cad8cfdf545dc0f7e7751bf43979552bb980f7fcb4b7e>,
  s: <BN: 1839adef53808d6e3ffba1f40495827cc6b4fa047d2c03dfe9ab76933581d35b>,
  recoveryParam: 1 }
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: Connect Failed
    at /usr/src/app/node_modules/grpc/src/node/src/client.js:554:15
(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'stack' of undefined

从日志中,在错误消息之前,我可以看到尝试连接:{"grpc.ssl_target_name_override":"peer0.org1.example.com","grpc.default_authority":"peer0.org1.example.com"}。也许 grpc 这里应该是 grpcs 因为网络使用 TLS。如果是,我的配置还有什么地方错了。有什么提示,建议吗?

谢谢!

已解决!

我在 olegabu 的有用评论后解决了这个问题。我将 REST API 用于 Hyperledger fabric..

我仍然遇到同样的错误 - sendPeersProposal - Promise is rejected: Error: Connect Failed - 当我 运行 以下请求时:加入频道上的同行,安装链码,实例化链码.尽管有错误,对等点仍然能够加入通道,并且通道对对等点可用。最后,我能够调用和查询分类帐。

P.S。我对 olegabu 的回答的赞成不能公开显示,因为我在 Whosebug 上的声誉不足以做到这一点。不过还是很感谢他的帮助,谢谢!

Gio,问题出在连接的某个地方,但我不能马上说出来:在 Whosebug 中你提到了

node.js API 暴露在端口 4000 上,然后 dockerized 并与端口 9999 桥接。

你能分享你的回购协议让我看看吗?

我要做的第一件事是附加到你的对等码头工人,看看是否可以从它访问其他节点,以及证书文件是否可用。您正在使用 TLS(来自协议中的 grpcs,我是否应该假设 TLS__ENABLE 也适用于对等方?)因此您的端点需要能够看到其对方的根证书文件("tls_cacerts" 在网络中- config.js.

您可能想看看 https://github.com/olegabu/fabric-starter 这个 repo 有脚本部署到一个或多个服务器,有一个 REST API 服务器和一个调试网络应用程序。它使用的链代码是您正在试验的余额转移。也许这个 repo 做了你想做的事情并且已经解决了这些问题。