Error while sending query request from client : No

2019-08-23 17:52发布

I am getting the following error while sending query request from my client.

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"]. 

Following is my the part of my connection-org3.json connection profile file

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

And following is a part of my docker composer file.

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

I got this code from Fabcar sample and tried to query from a client in Org3 instead of Org1. I created an admin user and then created a user in this organization successfully. According to my observations, I am getting the error from following code line execution.

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

What is the possible reason for this issue? Appreciate your insights on this.

Updates:

I checked opened ports in 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  

Here I can see ports 11051 and 11052 are open and listening.

Also, there is a container for the installed chain code.

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

When I look at the logs of that peer(peer0.org3) I can see floowing error log is print continuously. It is complaining about the connection with 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

2条回答
祖国的老花朵
2楼-- · 2019-08-23 18:17

You could check, if peer is accessible even using browser(Firefox). request on firefox - localhost:11051 if you could see the response means your peer is accessible or if not means your port is not open for the same, then go to the docker file and open the port for the same, and up the peer using docker compose , do the same for every peer you want to access.

Even you could check the logs of peers using following -

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

Update : ---

You could check CORE_PEER_GOSSIP_BOOTSTRAP & CORE_PEER_GOSSIP_EXTERNALENDPOINT for both peers

**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
  • Check Port accordingly your peers & up your docker file.
查看更多
唯我独甜
3楼-- · 2019-08-23 18:31

This could be due to multiple reasons:

  1. Your peers are not accessible so first check if these ports are open or not.

  2. You should confirm if the chaincode is installed on these peers or not.

  3. If these are not the cases then you must check the logs inside the docker containers of the chaincode and these peers and for that you can use:

docker exec -it [container-name] bash

Do tell me if you find something there and you can't resolve it.

查看更多
登录 后发表回答