0

I have a problem that there is always a grpcs timeout when installing the chaincode using fabric-sdk-go. The GRCPS request is made from the local machine to its docker containers.

ErrorMsg:

lscc.getinstalledchaincodes failed: SendProposal failed: Transaction processing for endorser [localhost:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection timed out [localhost:7051]

ENV:

Mac OSX

docker version: 18.03.1-ce

docker-compose version 1.21.1, build 5a3f1a3

fabric-sdk-go: master

The local fabric network is set up by the official fabric-ca example.

docker-compose.yaml: Gist

local network-config.yaml: Gist

client go app: Gist

Is there anything wrong with my network-config.yaml???

What I've tried:

  1. Tried to disable CORE_PEER_TLS_CLIENTAUTHREQUIRED in docker-compose.yaml, failed..

  2. Edited /etc/hosts file with the line 127.0.0.1 peer1-xiaoyudian..., failed..

  3. Increased the peer.timeout.connections and others timeout options in network-config.yaml, failed..

  4. Increased the grpcOptions.keep-alive-time in network-config.yaml, failed..

  5. Changed the host of peers.xxxx.url from localhost to the domain in network-config.yaml, failed...

  6. Added the entityMathcers in network-config.yaml, failed...

  7. Failed....

Answer: Someone from the rocket.chat told me:

  1. run: export GRPC_GO_LOG_SEVERITY_LEVEL=error
  2. run: export GRPC_GO_LOG_VERBOSITY_LEVEL=2
  3. in the client code add this line: grpclog.SetLogger(logger)

And the log says it a certificate issue for handshaking with peers.

Dean Zhao
  • 99
  • 3
  • 13

2 Answers2

1

You could try change localhost to domain in network. Ex: with peer: localhost -> peer1-xiaoyudian... with orderer: localhost -> orderer1-themis... same with ca, and use entity matcher to map peer name, orderer, ca with your ip address.

hieu.lt
  • 61
  • 7
  • entityMatchers: peer: - pattern: (\w+)-xiaoyudian:(\d+) urlSubstitutionExp: localhost:$2 sslTargetOverrideUrlSubstitutionExp: $1-xiaoyudian mappedHost: peer1-xiaoyudian - pattern: (\w+)-xiaoyudian:(\d+) urlSubstitutionExp: localhost:$2 sslTargetOverrideUrlSubstitutionExp: $1-xiaoyudian mappedHost: peer2-xiaoyudian – Dean Zhao Jun 12 '18 at 04:11
  • Please see the latest question edit for a better format. – Dean Zhao Jun 12 '18 at 04:15
  • I think you should change "localhost" in all section orderer, peer, ca to its domain, because when all this components communication with each others, it calls through domain. Could try edit like this: orderers: orderer1-themis: url: grpcs://orderer1-themis:7050 ... peers: peer1-xiaoyudian: url: grpcs://peer1-xiaoyudian:7051 eventUrl: grpcs://peer1-xiaoyudian:7053 ... – hieu.lt Jun 12 '18 at 04:34
  • [latest network-config.yaml](https://gist.github.com/RealDeanZhao/dd53b5a1cac227f03c4d2ac815af1271) Still not work. – Dean Zhao Jun 12 '18 at 04:50
  • if err = c.verifyPeerConfig(p, peerName, endpoint.IsTLSEnabled(p.URL)); err != nil { logger.Debugf("Could not verify Peer for [%s], trying with Entity Matchers", peerName) matchingPeerConfig, matchErr := c.tryMatchingPeerConfig(peerName) I debug into the sdk-go code and it seems that the entity matcher will never be used since 'verifyPeerConfig' will not return nil error – Dean Zhao Jun 12 '18 at 06:06
  • You could try edit hosts file, add this line like this: 127.0.0.1 ica-xiaoyudian orderer1-themis peer1-xiaoyudian peer2-xiaoyudian This work for me – hieu.lt Jun 12 '18 at 06:39
  • Tried nearly 20 solutions including the /etc/host file and nothing worked... : ( – Dean Zhao Jun 12 '18 at 07:12
1

Refer https://github.com/hyperledger/fabric-sdk-go/tree/master/test/fixtures/config/overrides for how URLs are overridden to use localhost. In your case, you have to use local_entity_matchers.yaml & local_orderers_peers_ca.yaml combined in samples provided.

One more thing I noticed in your network-config.yaml, mapped host name is same as actual peer name. Entity matcher doesn't kick in here. Refer the entity matchers used in the sample given above.

  • Thanks. I changed it to the different mapped host name, the entity matcher works.. But the timeout issue still exists. – Dean Zhao Jun 13 '18 at 01:42