简体   繁体   English

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

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

I followed the tutorial Using Google OAUTH 2.0 with a REST server to persist the business network cards using the MongoDB Docker images. 我遵循了将REST服务器与Google OAUTH 2.0一起使用的教程, 使用MongoDB Docker映像持久化商务网卡。 I am trying to build a web application in which there are two composer rest servers. 我正在尝试构建一个包含两个作曲家其余服务器的Web应用程序。

The first one has no authentication, and allow users to create a new participant and to issue a new card. 第一个没有身份验证,并且允许用户创建新的参与者和发行新的卡。

At this point, the second composer REST server, after authentication (with Google OAUTH2.0) should allow users to perform all the other operations. 此时,第二个作曲者REST服务器(通过Google OAUTH2.0身份验证)应允许用户执行所有其他操作。 Anyway, I keep receiving the 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] 错误:呼叫注册端点失败,并显示错误[错误:连接ECONNREFUSED 127.0.0.1:7054]

I am almost sure that the problem is that since the REST server is in docker, the file connection.json in the business cards should be changed in order for the host to be reachable. 我几乎可以确定问题在于,由于REST服务器位于docker中,因此应更改名片中的文件connection.json以便主机可访问。

I already did this for the card that I used to install and start the network, so now the file for that card is: 我已经对用于安装和启动网络的卡进行了此操作,因此该卡的文件为:

{"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"}
}

} }

But my question is, how do I change this file for every new card issued by the REST server? 但是我的问题是,如何为REST服务器发行的每张新卡更改此文件? Is there a way to configure the REST server to do this automatically? 有没有一种方法可以将REST服务器配置为自动执行此操作?

Assuming you are running 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). 假设您在本地运行一个简单的Fabric(例如Composer Tools提供的Development Fabric),则可以利用Docker Port Forwarding连接到本地主机(通常为127.0.0.1)上的Fabric。 However when you are running inside a Docker container localhost just reflects back into the container, so the port forwarding on the Docker host is not used. 但是,当您在Docker容器中运行时,localhost只会反射回该容器,因此不使用Docker主机上的端口转发。 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. 本教程为该容器创建了一个专用的“ restadmin”卡,该卡用包含Fabric容器的容器名称的URL替换了localhost URL,并且由于它们使用相同的Docker网络桥(composer_default),因此一切正常。

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. 当您使用Composer REST服务器发布身份时,将使用“当前” ID的Connection.json发出新的身份(和卡)。

So I'm guessing that in your case you have your first REST server (no authentication) running locally NOT in a container, and the 2nd Multi User REST server running inside a container. 因此,我想在您的情况下,您的第一个REST服务器(无身份验证)不在容器中本地运行,而第二个多用户REST服务器在容器中运行。 So you have a mismatch between the Fabric URLs of the 2 REST servers. 因此,您在2个REST服务器的结构URL之间不匹配。

Maybe the solution is to run them both locally, or Both as Containers, so that the cards between the servers will be consistent. 也许解决方案是同时在本地或作为容器运行它们,以便服务器之间的卡保持一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hyperledger Composer Rest服务器未更新 - Hyperledger composer rest server not updating 如何将Hyperledger Composer Rest服务器连接到自己创建的身份验证? - How to connect hyperledger composer rest server to own created authentication? Hyperledger-Composer-Rest-Server-REST API公共 - Hyperledger-Composer-Rest-Server - REST API public 无法向Java中经过身份验证的Hyperledger Composer REST服务器发出发布请求 - Not able to do a post request to an authenticated Hyperledger Composer rest server in Java Hyperledger Composer Developer教程中启动REST服务器的问题 - Issue with starting the REST server in Hyperledger Composer Developer Tutorial 如何在Hyperledger Composer Rest Server的POST请求中为参数提供空值 - How to give empty value for argument in POST request for hyperledger composer rest server Hyperledger Composer v0.16.2 Rest Server错误 - Hyperledger composer v0.16.2 Rest server error 无护照使用Hyperledger Composer REST Server多用户 - Using Hyperledger Composer REST Server multiuser without passport Hyperledger Composer REST Server即使事务失败也返回200 - Hyperledger Composer REST Server returns 200 even when transaction fails 如何将Hyperledger Composer Rest API分配到外部IP - How to Delpoy the Hyperledger Composer Rest API to an External IP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM