Composer rest服务器无法连接到ca.org1.example.com

时间:2018-04-01 19:28:58

标签: docker hyperledger-fabric hyperledger-composer

我跟着this tutorial设置了myorg/composer-rest-server,一切正常,直到我导入卡片,但是当我向/api/system/ping发出GET请求时,它返回500错误:

{"error":{"statusCode":500,"name":"Error","message":"Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]","stack":"Error: Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]\n    at client.getUserContext.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:393:34)\n    at <anonymous>\n    at process._tickDomainCallback (internal/process/next_tick.js:228:7)"}}

所以我检查了日志容器的日志,它似乎找不到127.0.0.1:7054。这是错误日志。

Unhandled error for request GET /api/system/ping: Error: Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at client.getUserContext.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:393:34)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)

所以我检查了容器ca.org1.example.com的日志,它正在侦听端口7054

2018/04/01 09:57:25 [DEBUG] CA initialization successful
2018/04/01 09:57:25 [INFO] Home directory for default CA: /etc/hyperledger/fabric-ca-server
2018/04/01 09:57:25 [DEBUG] 1 CA instance(s) running on server
2018/04/01 09:57:25 [INFO] Listening on http://0.0.0.0:7054

我认为我需要将127.0.0.1更改为0.0.0.0,但不确定如何以正确的方式执行此操作。也可能是防火墙问题? 这是我的.composer/cards/restadmin@myserver/connection.json

{"name":"hlfv1","x-type":"hlfv1","x-commitTimeout":300,"version":"1.0.0","client":{"organization":"Org1","connection":{"timeout":{"peer":{"endorser":"300","eventHub":"300","eventReg":"300"},"orderer":"300"}}},"channels":{"composerchannel":{"orderers":["orderer.example.com"],"peers":{"peer0.org1.example.com":{}}}},"organizations":{"Org1":{"mspid":"Org1MSP","peers":["peer0.org1.example.com"],"certificateAuthorities":["ca.org1.example.com"]}},"orderers":{"orderer.example.com":{"url":"grpc://orderer.example.com:7050"}},"peers":{"peer0.org1.example.com":{"url":"grpc://peer0.org1.example.com:7051","eventUrl":"grpc://peer0.org1.example.com:7053"}},"certificateAuthorities":{"ca.org1.example.com":{"url":"http://ca.org1.example.com:7054","caName":"ca.org1.example.com"}}}

我正在使用AWS EC2

  • OS:Ubuntu 16.04.3 LTS,
  • Docker:17.12.0-ce,
  • 作曲家:v0.19.0
  • 面料:v1.1

1 个答案:

答案 0 :(得分:0)

您导入了哪张卡?如果是restadmin卡,我想你可能已经导入了一张包含过期的一次性秘密的卡。在使用其他管理卡启动REST服务器(在容器中)之后,秘密被替换为证书 - 因此,如果再次使用其他名称composer card export -c restadmin@trade-network -f restadmin-cert.card导出restadmin卡,您将看到它是一个更大的文件因为证书。您应该能够导入并使用这个新的.card文件。

(如果您使用的是其他卡,例如jdoe - 您是否运行此卡的sed命令来更正地址?)