温馨提示:本文翻译自stackoverflow.com,查看原文请点击:hyperledger fabric - Error while sending query request from client : No peer available to query

hyperledger fabric - 从客户端发送查询请求时出错:没有可用于查询的同位体

发布于 2020-03-27 10:55:25

从客户端发送查询请求时出现以下错误。

FabricError: No peers available to query. Errors: ["Failed to connect before the deadline 
URL:grpcs://localhost:12051","Failed to connect before the deadline 
URL:grpcs://localhost:11051"]. 

以下是我属于我的connection-org3.json连接配置文件的一部分

"organizations": {
        "Org3": {
            "mspid": "Org3MSP",
            "peers": [
                "peer0.org3.bc4scm.de",
                "peer1.org3.bc4scm.de"
            ],
            "certificateAuthorities": [
                "ca.org3.bc4scm.de"
            ]
        }
    },
    "peers": {
        "peer0.org3.bc4scm.de": {
            "url": "grpcs://localhost:11051",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/org3.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org3.bc4scm.de"
            }
        },
        "peer1.org3.bc4scm.de": {
            "url": "grpcs://localhost:12051",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/supplier.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer1.org3.bc4scm.de"
            }
        }
    },
    "certificateAuthorities": {
        "ca.org3.bc4scm.de": {
            "url": "https://localhost:9054",
            "caName": "ca-supplier",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/org3.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "httpOptions": {
                "verify": false
            }
        }
    }

以下是我的docker composer文件的一部分。

peer0.org3.bc4scm.de:
    container_name: peer0.org3.bc4scm.de
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org3.bc4scm.de
      - CORE_PEER_ADDRESS=peer0.org3.bc4scm.de:11051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:11051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org3.bc4scm.de:11052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.bc4scm.de:12051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.bc4scm.de:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer0.org3.bc4scm.de/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer0.org3.bc4scm.de/tls:/etc/hyperledger/fabric/tls
      - peer0.org3.bc4scm.de:/var/hyperledger/production
    ports:
      - 11051:11051

  peer1.org3.bc4scm.de:
    container_name: peer1.org3.bc4scm.de
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org3.bc4scm.de
      - CORE_PEER_ADDRESS=peer1.org3.bc4scm.de:12051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:12051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org3.bc4scm.de:12052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:12052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.bc4scm.de:11051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.bc4scm.de:12051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer1.org3.bc4scm.de/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/supplier.bc4scm.de/peers/peer1.org3.bc4scm.de/tls:/etc/hyperledger/fabric/tls
      - peer1.org3.bc4scm.de:/var/hyperledger/production
    ports:
    - 12051:12051

我从Fabcar示例中获取了此代码,并尝试从Org3(而不是Org1)中的客户端进行查询。我创建了一个管理员用户,然后在该组织中成功创建了一个用户。根据我的观察,我从以下代码行执行中得到错误。

const result = await contract.evaluateTransaction('queryAllProducts','123');

此问题的可能原因是什么?赞赏您对此的见解。

更新:

我在peer0.prg3.bs4scm.de中检查了打开的端口

root@e52992a76c3d:/opt/gopath/src/github.com/hyperledger/fabric/peer# netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:9443          0.0.0.0:*               LISTEN      1/peer          
tcp        0      0 127.0.0.11:46353        0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::11051                :::*                    LISTEN      1/peer          
tcp6       0      0 :::6060                 :::*                    LISTEN      1/peer          
tcp6       0      0 :::11052                :::*                    LISTEN      1/peer  

在这里,我可以看到端口11051和11052已打开并正在侦听。

另外,还有一个用于安装链码的容器。

cd0b165e5186        dev-peer0.org3.bc4scm.de-scmlogic-1.0-9c7e776aa8a752e530f79d0b456f1bda28aac3f5db0af734be2f315d8d1a4f53   "/bin/sh -c 'cd /usr…"   48 seconds ago       Up 47 seconds                                                     dev-peer0.org3.bc4scm.de-scmlogic-1.0

当我查看该对等方(peer0.org3)的日志时,可以看到连续显示错误消息日志。它抱怨与org1的连接

019-07-06 10:26:52.278 UTC [gossip.discovery] expireDeadMembers -> WARN 164 Exiting
2019-07-06 10:26:56.381 UTC [gossip.comm] func1 -> WARN 165 peer1.org1.bc4scm.de:8051, PKIid:42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a9d0441d772925882d4457a7 isn't responsive: EOF
2019-07-06 10:26:56.381 UTC [gossip.discovery] expireDeadMembers -> WARN 166 Entering [42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a9d0441d772925882d4457a7]
2019-07-06 10:26:56.381 UTC [gossip.discovery] expireDeadMembers -> WARN 167 Closing connection to Endpoint: peer1.org1.bc4scm.de:8051, InternalEndpoint: , PKI-ID: 42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a

查看更多

查看更多

提问者
Malintha
被浏览
81
Artho 2019-07-06 19:26

您可以检查是否可以使用浏览器(Firefox)访问对等项。request on firefox - localhost:11051如果您可以看到响应表示您的对等方是可访问的或者不是您的对等方的端口未打开,则转到docker文件并为该对等方打开端口,然后使用docker compose在对等方上进行操作您要访问的每个对等体。

您甚至可以使用以下命令查看对等方的日志-

docker logs --follow peer0.org3.bc4scm.de

更新:-

您可以为两个同伴检查CORE_PEER_GOSSIP_BOOTSTRAP和CORE_PEER_GOSSIP_EXTERNALENDPOINT

**CORE_PEER_GOSSIP_BOOTSTRAP=<a list of peer endpoints within the peer's org>
CORE_PEER_GOSSIP_EXTERNALENDPOINT=<the peer endpoint, as known outside the org>**


for peer0.org3.bc4scm.de

CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.bc4scm.de:12051
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.bc4scm.de:11051

for peer1.org3.bc4scm.de : 

CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.bc4scm.de:11051
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.bc4scm.de:12051
  • 相应地检查端口您的同伴和您的docker文件。

发布
问题

分享
好友

手机
浏览

扫码手机浏览