错误:在 Endorser 截止日期之前无法连接 - 名称:peer0.org1.example.com,url:grpcs://localhost:7051

问题描述 投票:0回答:1

我正在使用

test-network
部署我的链码,如下所示:

./network.sh up createChannel -c mychannel -ca

./network.sh deployCC -ccn mychaincode -ccp /.../mychaincode/ -ccl javascript

网络启动后,我注意到文件夹

.../fabric-samples/test-network/organizations/peerOrganizations
已创建。因此,我将以下
json
文件复制到我的 Nodejs 项目的
config
文件夹中:

.../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.json

.../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/connection-org2.json

因此,当我提交交易时,我使用

Org1
进行组织,并从
.../config/connection-org1.json
获取连接配置文件,这是我复制到我的 Nodejs 项目文件夹中的连接配置文件。 然后我在调用
contract.submitTransaction("CallMyMethod", ...args)
时收到以下错误:

error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com, url:grpcs://localhost:7051, connected:false, connectAttempted:true
error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.org1.example.com url:grpcs://localhost:7051 timeout:3000
info: [NetworkConfig]: buildPeer - Unable to connect to the endorser peer0.org1.example.com due to Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com, url:grpcs://localhost:7051, connected:false, connectAttempted:true 
    at checkState (/.../mynodejsproject/node_modules/@grpc/grpcjs/build/src/client.js:77:26) 
    at Timeout._onTimeout (/.../mynodejsproject/node_modules/@grpc/grpcjs/build/src/channel.js:525:17) 
    at listOnTimeout (node:internal/timers:564:17)
    at process.processTimers (node:internal/timers:507:7) { connectFailed: true }
error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Discoverer- name: peer0.org1.example.com, url:grpcs://localhost:7051, connected:false, connectAttempted:true
error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.org1.example.com url:grpcs://localhost:7051 timeout:3000
error: [ServiceEndpoint]: ServiceEndpoint grpcs://localhost:7051 reset connection failed :: Error: Failed to connect before the deadline on Discoverer- name: peer0.org1.example.com, url:grpcs://localhost:7051, connected:false, connectAttempted:true
error: [DiscoveryService]: send[mychannel] - no discovery results

如果我通过命令行从

test-network
目录提交交易,如下所示,一切都很好。

export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:7051

peer chaincode query -C mychannel -n basic -c '{"Args":["CallMyMethod"]}'

但是,当从我的 Nodejs 应用程序调用时,我收到了

Failed to connect before deadline
错误。我使用的是 mac 和 docker 桌面。除了引用我从
connection-org1.json
文件夹复制的
test-network
之外,我还需要做其他事情吗?

hyperledger-fabric hyperledger
1个回答
0
投票

问题在于,每次网络关闭和启动时,tlsCACerts pem 都会更新。

解决此问题的简单方法应该是将“pem”替换为“path”,如下所示 -

tlsCACerts:
      path: <certpath>

(这需要为订购者和组织中的所有同行完成)

或者您可以在每次重新运行网络时替换 CCP 文件。

© www.soinside.com 2019 - 2024. All rights reserved.