我收到以下提到的错误。
我已经建立了一个Hyperledger Fabric网络,其中有2个arg,每个都有一个对等体。我已经在Docker容器中创建,安装并实例化了链码,并且它们工作正常。我使用node.js SDK来注册管理员和注册用户(类似于fabcar)。成功注册用户后,我尝试连接到频道(query.js)。我遇到错误Channel:mychannel received discovery error:access denied.
,请帮我解决此问题。
错误
2020-07-30T20:02:58.852Z - error: [Channel.js]: Channel:mychannel received discovery error:access denied 2020-07-30T20:02:58.853Z - error: [Channel.js]: Error: Channel:mychannel Discovery error:access denied 2020-07-30T20:02:58.853Z - error: [Network]: _initializeInternalChannel: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: Channel:mychannel Discovery error:access denied Failed to evaluate transaction: Error: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: Channel:mychannel Discovery error:access denied
导航到我发现的对等日志
2020-07-30 20:01:27.729 UTC [discovery] processQuery -> WARN 063 got query for channel mychannel from 172.21.0.1:39964 but it isn't eligible: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied
2020-07-30 20:01:27.729 UTC [discovery] processQuery -> WARN 064 got query for channel mychannel from 172.21.0.1:39964 but it isn't eligible: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Writers' sub-policies to be satisfied
2020-07-30 20:01:27.729 UTC [comm.grpc.server] 1 -> INFO 065 unary call completed grpc.service=discovery.Discovery grpc.method=Discover grpc.peer_address=172.21.0.1:39964 grpc.code=OK grpc.call_duration=960.632µs.
订单日志
: go1.12.12
OS/Arch: linux/amd64
2020-07-30 19:45:19.010 UTC [orderer.common.server] Start -> INFO 008 Beginning to serve requests
2020-07-30 19:49:35.018 UTC [comm.grpc.server] 1 -> INFO 009 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.21.0.6:47634 grpc.code=OK grpc.call_duration=17.59346ms
2020-07-30 19:49:35.021 UTC [fsblkstorage] newBlockfileMgr -> INFO 00a Getting block information from block storage
2020-07-30 19:49:35.131 UTC [orderer.commmon.multichannel] newChain -> INFO 00b Created and starting new chain mychannel
2020-07-30 19:49:35.134 UTC [comm.grpc.server] 1 -> INFO 00c streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.21.0.6:47632 grpc.code=OK grpc.call_duration=140.497072ms
2020-07-30 19:53:41.978 UTC [orderer.common.broadcast] Handle -> WARN 00d Error reading from 172.21.0.6:47718: rpc error: code = Canceled desc = context canceled
2020-07-30 19:53:41.978 UTC [comm.grpc.server] 1 -> INFO 00e streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.21.0.6:47718 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=3.667041ms
2020-07-30 19:53:49.541 UTC [comm.grpc.server] 1 -> INFO 00f streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.21.0.3:41404 grpc.code=OK grpc.call_duration=3.734645ms
2020-07-30 19:56:07.720 UTC [orderer.common.broadcast] Handle -> WARN 010 Error reading from 172.21.0.6:47906: rpc error: code = Canceled desc = context canceled
2020-07-30 19:56:07.720 UTC [comm.grpc.server] 1 -> INFO 011 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.21.0.6:47906 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=5.159439458s
2020-07-30 20:00:15.785 UTC [orderer.common.broadcast] Handle -> WARN 012 Error reading from 172.21.0.6:48010: rpc error: code = Canceled desc = context canceled
Configtx.yaml
Organizations:
- &ordererOrg
Name: Orderer
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/orderer.immume.com/msp
- &Org1
Name: Org1
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.immume.com/msp
AnchorPeers:
- Host: peer0.org1.immume.com
Port: 7051
- &Org2
Name: Org2
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.immume.com/msp
AnchorPeers:
- Host: peer0.org2.immume.com
Port: 8051
Capabilities:
Channel: &ChannelMyCapabilities
V1_3: true
Orderer: &OrderMyCapabilities
V1_1: true
Application: &ApplicationMyCapabilities
V1_3: true
V1_2: false
V1_1: false
Application: &ApplicationMyDefaults
Organizations:
Orderer: &OrdererMyDefault
OrdererType: solo
Addresses:
- orderer.orderer.immume.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 40
AbsoluteMaxBytes: 98 MB
PreferredMaxBytes: 4354 KB
Profiles:
myGenesisProfile:
Capabilities:
<<: *ChannelMyCapabilities
Orderer:
<<: *OrdererMyDefault
Organizations:
- *ordererOrg
Capabilities:
<<: *OrderMyCapabilities
Consortiums:
myconsortium:
Organizations:
- *Org1
- *Org2
mychannel:
Consortium: myconsortium
Application:
<<: *ApplicationMyDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationMyCapabilities
newchannel:
Consortium: myconsortium
Application:
<<: *ApplicationMyDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationMyCapabilities
我还附上了屏幕截图,以更好地参考对等日志,订单日志,query.js,connection.yaml,docker容器调用和查询
答案 0 :(得分:0)
如果尚未配置或未使用发现服务,请在文件query.js
中将其禁用。
通过在语句discovery: { enabled: false }
中设置await gateway.connect(ccp, { wallet, identity: 'appUser', discovery: { enabled: true, asLocalhost: true } });
来发现发现服务
答案 1 :(得分:0)
在query.js中使用服务发现选项"asLocalhost": false
。
由于该应用程序在区块链网络外部运行。
然后还将connection.yaml中的url更改为容器的主机名,而不是localhost或127.0.0.1。 例如这样的
orderers:
orderer.example.com:
url: grpcs://orderer.example.com:7050 // like this
grpcOptions:
ssl-target-name-override: orderer.example.com
tlsCACerts:
path: ./caro-blockchain-commonfiles/config/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peers:
peer0.org1.example.com:
url: grpcs://peer0.org1.example.com:7051 // like this
grpcOptions:
ssl-target-name-override: peer0.org1.example.com
tlsCACerts:
path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem
peer0.org2.example.com:
url: grpcs://peer0.org2.example.com:9051 // like this
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
tlsCACerts:
path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem
最后检查应用程序,它是否与Blockchain Services位于同一网络中。
docker network connect networkNameBlockchain containerNameOfApp