如何修改Hyperledger Composer REST服务器发行的卡片中的connection.json文件

How to modify the connection.json file in the cards issued by the Hyperledger Composer REST server

我按照教程 Using Google OAUTH 2.0 with a REST server 使用 MongoDB Docker 图像来保存业务网络名片。 我正在尝试构建一个 Web 应用程序,其中有两个作曲家休息服务器。

第一个没有身份验证,允许用户创建新参与者并发行新卡。

此时,第二个 composer REST 服务器在经过身份验证后(使用 Google OAUTH2.0)应该允许用户执行所有其他操作。 无论如何,我一直收到错误:

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]

我几乎可以肯定问题是因为 REST 服务器在 docker 中,所以名片中的文件 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"}
},
"certificateAuthorities":
{
    "ca.org1.example.com":
    {"url":"http://ca.org1.example.com:7054","caName":"ca.org1.example.com"}
}

}

但我的问题是,如何为 REST 服务器发布的每张新卡更改此文件?有没有办法将 REST 服务器配置为自动执行此操作?

Assuming you are 运行ning a simple Fabric locally (such as the Development Fabric provided by the Composer Tools) then you take advantage of Docker Port Forwarding to connect to the Fabric on localhost (usually 127.0.0.1). However when you are 运行ning inside a Docker container localhost just reflects back into the container, so the port forwarding on the Docker host is not used. The tutorial creates a dedicated 'restadmin' card for the container which replaces the localhost URLs with URLs containing the container names for the Fabric containers, and because they use the same Docker networking bridge (composer_default) it all works ok.

When you Issue an Identity with the Composer REST server, the new identity (and card) is issued with the Connection.json of the 'current' ID.

So I'm guessing that in your case you have your first REST server (no authentication) 运行ning locally NOT in a container, and the 2nd Multi User REST server 运行ning inside a container. So you have a mismatch between the Fabric URLs of the 2 REST servers.

Maybe the solution is to 运行 them both locally, or Both as Containers, so that the cards between the servers will be consistent.