尝试在 hyperledger composer rest 中执行操作时出错 API

Error when trying to carry out operations in hyperledger composer rest API

从本教程开始,我使用 Docker 为 hyperledger composer 业务网络设置了一个持久且安全的 REST 服务器:https://hyperledger.github.io/composer/integrating/deploying-the-rest-server.html

然而,当我尝试在 RESTful APi 上执行任何命令时,出现以下错误:

Unhandled error for request GET /api/Contract: 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]

有谁知道是什么导致了这个错误?

嗯嗯,这都是本地开发环境吗?如示例连接配置文件中指定的那样 here - the CA server is meant to be listening on port 7054. So the problem is it can't contact your CA server to verify the identity of the REST /GET request. Not sure if you have any 。确实检查一下你所有的面料是否都起来了 运行 docker ps。假设您以非特权用户身份执行此操作,并以 npm install 作为非特权用户全局安装了 Composer。

可能您必须更改端点 IP 地址,因为您正在 docker 化 REST API,它将不再是同一台机器上的所有服务,因此,当联系 127.0.0.1:7054 时,它最终将无法访问,因为服务不在 docker 容器内。

要解决此问题,请将 127.0.0.1 IP 更改为您的主机 IP(即 192.168.0.2),然后重试。还要确保,如果您使用 docker 并且希望从外部容器获得服务,则必须映射容器端口。

确保 docker 个实例处于活动状态。 第一次启动新的运行时,需要运行启动脚本,然后生成PeerAdmin卡

cd ~/fabric-tools
./startFabric.sh
./createPeerAdminCard.sh

参考:starting hyperledger fabric