Hyperledger composer rest server:尝试ping时出错。错误:没有可用于查询的对等项。最后一个错误是错误:14 UNAVAILABLE:连接失败

时间:2018-05-13 03:26:38

标签: docker hyperledger-fabric hyperledger hyperledger-composer

在Hyperledger作曲家下,我试图通过多组织设置使用googleauth2.0设置一个持久的Rest服务器。

对于多组织设置,我已关注https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org,对于谷歌身份验证设置,我已关注https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest

当我尝试使用以下命令为REST服务器启动扩展Docker镜像的新实例时,一切顺利,直到后续步骤

docker run
-d
-e COMPOSER_CARD=${COMPOSER_CARD}
-e COMPOSER_NAMESPACES=${COMPOSER_NAMESPACES}
-e COMPOSER_AUTHENTICATION=${COMPOSER_AUTHENTICATION}
-e COMPOSER_MULTIUSER=${COMPOSER_MULTIUSER}
-e COMPOSER_PROVIDERS="${COMPOSER_PROVIDERS}"
-e COMPOSER_DATASOURCES="${COMPOSER_DATASOURCES}"
-v ~/.composer:/home/composer/.composer
--name rest
--network composer_default
-p 3001:3001
org1/composer-rest-server

以下是来自rest容器的日志:

[2018-05-13 02:38:15] PM2 log: Launching in no daemon mode
[2018-05-13 02:38:16] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-05-13 02:38:16] PM2 log: App name:composer-rest-server id:0 online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Discovering types from business network definition ...
Connection fails: Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
It will be retried for the next request.
Exception: Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
    at _checkRuntimeVersions.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:790:34)
    at <anonymous>
[2018-05-13 02:38:29] PM2 log: App [composer-rest-server] with id [0] and pid [14], exited with code [1] via signal [SIGINT]

以下是泊坞容器:

233938f12ef0        org1/composer-rest-server                                                                                "pm2-docker composer…"   30 minutes ago      Up 30 minutes       3000/tcp, 0.0.0.0:3001->3001/tcp                   rest
6285853fdceb        dev-peer1.org1.example.com-emcs-0.0.3-b1bb3a7f1090c0d1cabf10340188aa72e329e1266595f63d232d9cc38a0ed8b8   "/bin/sh -c 'cd /usr…"   About an hour ago   Up About an hour                                                       dev-peer1.org1.example.com-emcs-0.0.3
1a4f7680cac9        dev-peer0.org1.example.com-emcs-0.0.3-094e3600469176994df7048ec5afad4114ce5203fe267b0c45da52a3d3b9e0b7   "/bin/sh -c 'cd /usr…"   About an hour ago   Up About an hour                                                       dev-peer0.org1.example.com-emcs-0.0.3
b7c7364c88bd        dev-peer0.org2.example.com-emcs-0.0.3-3f76658cf8352417e15be589ed41aa0fa81e702a1bdb6e7e1ce898a015fdd34c   "/bin/sh -c 'cd /usr…"   About an hour ago   Up About an hour                                                       dev-peer0.org2.example.com-emcs-0.0.3
b154cd4f50bd        dev-peer1.org2.example.com-emcs-0.0.3-340eb1dbb0152185d068724d637848c882bd3754f7c9888d57c80bdfb6530774   "/bin/sh -c 'cd /usr…"   About an hour ago   Up About an hour                                                       dev-peer1.org2.example.com-emcs-0.0.3
f9d2a72fde40        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab     "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer1.org2.example.com-mycc-1.0
d812bef3a1bd        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9     "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer0.org1.example.com-mycc-1.0
ccb70e752d7b        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b     "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer0.org2.example.com-mycc-1.0
6989f8850296        hyperledger/fabric-tools                                                                                 "/bin/bash -c './scr…"   2 hours ago         Up 2 hours                                                             cli
0eabbd6be684        hyperledger/fabric-peer                                                                                  "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
d8c1146a5989        hyperledger/fabric-peer                                                                                  "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
142aeb4525ab        hyperledger/fabric-peer                                                                                  "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
70ef571ea1ba        hyperledger/fabric-peer                                                                                  "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
31c8417beae2        hyperledger/fabric-ca                                                                                    "sh -c 'fabric-ca-se…"   2 hours ago         Up 2 hours          0.0.0.0:8054->7054/tcp                             ca_peerOrg2
ade3061fc517        hyperledger/fabric-orderer                                                                               "orderer"                2 hours ago         Up 2 hours          0.0.0.0:7050->7050/tcp                             orderer.example.com
e315be1721d9        hyperledger/fabric-couchdb                                                                               "tini -- /docker-ent…"   2 hours ago         Up 2 hours          4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp         couchdb3
0197051ffaf6        hyperledger/fabric-couchdb                                                                               "tini -- /docker-ent…"   2 hours ago         Up 2 hours          4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp         couchdb1
5abd60481ec3        hyperledger/fabric-couchdb                                                                               "tini -- /docker-ent…"   2 hours ago         Up 2 hours          4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp         couchdb2
58205a7b26fe        hyperledger/fabric-ca                                                                                    "sh -c 'fabric-ca-se…"   2 hours ago         Up 2 hours          0.0.0.0:7054->7054/tcp                             ca_peerOrg1
13009c1401fb        hyperledger/fabric-couchdb                                                                               "tini -- /docker-ent…"   2 hours ago         Up 2 hours          4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp         couchdb0
1ef9ab29b607        mongo                                                                                                    "docker-entrypoint.s…"   2 hours ago         Up 2 hours          0.0.0.0:27017->27017/tcp                           mongo

我已经遇到了其他人收到的错误,因此已经执行了以下额外步骤:

  1. 使用以下命令更改〜/ .composer的权限:chmod -R 777~ / .composer
  2. 替换了我的网卡connection.json中的IP地址,建议使用0.0.0.0 在https://github.com/hyperledger/composer/issues/3002
  3. 我已经尝试清理所有的docker容器和图像,停止布料并启动布料但是它仍然会出现相同的错误..

    预期的行为是命令docker logs -f rest应该在http://localhost:3001/explorer浏览您的REST API完成。但是,它会导致上述错误。

2 个答案:

答案 0 :(得分:2)

Google Auth教程并不期望从multiorg教程中设置结构,因此如果您按照这些步骤进行操作,则无法正常工作。 Auth教程旨在使用开发结构提供的单一组织来设置编写器开发环境或运行单个组织教程。问题是connection.json需要描述多组织设置(所以你需要一个来自multi-org教程的适当的连接配置文件),并且当你在docker容器中运行你的rest服务器并附加到所有超级分层结构容器连接到您的网络都无法使用主机名和地址(如localhost127.0.0.10.0.0.0)来尝试解决不同的超级分层结构进程(所有这些都会实际请参阅您的休息服务器容器)。您需要使用正确的主机名来识别它们。例如

  订货人

orderer.example.com      

peer0.org1.example.com for peer0.org1.example.com(与其他同行类似)

     

org1中的证书颁发机构的ca0,org2中的证书颁发机构的ca1

答案 1 :(得分:2)

尝试在

中替换peer0.org1.example.compeer0.org1.example.comca.org1.example.comorderer.example.com
sed -e 's/localhost:7051/peer0.org1.example.com:7051/' \
    -e 's/localhost:7053/peer0.org1.example.com:7053/' \
    -e 's/localhost:7054/ca.org1.example.com:7054/' \
    -e 's/localhost:7050/orderer.example.com:7050/' \
    < $HOME/.composer/cards/restadmin@trade-network/connection.json \
    > /tmp/connection.json && \
    cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@trade-network/
使用IP地址的

命令,如:

sed -e 's/localhost:7051/192.168.0.170:7051/' \
    -e 's/localhost:7053/192.168.0.170:7053/' \
    -e 's/localhost:7054/192.168.0.170:7054/' \
    -e 's/localhost:7050/192.168.0.170:7050/' \
    < $HOME/.composer/cards/restadmin@trade-network/connection.json \
    > /tmp/connection.json && \
    cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@trade-network/