0

I'm setting up the development environment following the instructions on Hyperledger fabric's official website: https://hyperledger-fabric.readthedocs.io/en/latest/peer-chaincode-devmode.html I have started the orderer successfully using:

ORDERER_GENERAL_GENESISPROFILE=SampleDevModeSolo orderer

This command didn't work at first but it worked after I cd fabric/sampleconfig

2020-12-21 11:23:15.084 CST [orderer.common.server] Main -> INFO 009 Starting orderer:  Version: 2.3.0  Commit SHA: dc2e59b3c  Go version: go1.15.6  OS/Arch: darwin/amd64 
2020-12-21 11:23:15.084 CST [orderer.common.server] Main -> INFO 00a Beginning to serve requests

but when I start the peer using:

export PATH=$(pwd)/build/bin:$PATH 
export FABRIC_CFG_PATH=$(pwd)/sampleconfig
export FABRIC_LOGGING_SPEC=chaincode=debug
export CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
peer node start --peer-chaincodedev=true

An error is spotted:

FABRIC_LOGGING_SPEC=chaincode=debug 
CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
peer node start --peer-chaincodedev=true

2020-12-21 11:25:13.047 CST [nodeCmd] serve -> INFO 001 Starting peer:  Version: 2.3.0 Commit SHA: dc2e59b3c Go version: go1.15.6 OS/Arch: darwin/amd64 Chaincode: Base Docker Label: org.hyperledger.fabric   Docker Namespace: hyperledger
2020-12-21 11:25:13.048 CST [peer] getLocalAddress -> INFO 002 Auto-detected peer address: 10.200.83.208:7051 
2020-12-21 11:25:13.048 CST [peer] getLocalAddress -> INFO 003 Host is 0.0.0.0 , falling back to auto-detected address: 10.200.83.208:7051  Error: failed to initialize operations subsystem: listen tcp 127.0.0.1:9443: bind: address already in use

this is the error:

Error: failed to initialize operations subsystem: listen tcp 127.0.0.1:9443: bind: address already in use

I checked this issue and it seems this happens because the peer node is using the same port 9443 as the orderer node for the same service. How can I get the two nodes running separately? It seems the docker is running as well.

david_k
  • 5,843
  • 2
  • 9
  • 16

2 Answers2

1

If you see your error, you can easily follow
Error: failed to initialize operations subsystem: listen tcp 127.0.0.1:9443: bind: address already in use
It is said that the 9443 port is already in use.


It seems that you are not running the orderer and peer as separate containers on the docker-based virtual network, but running on the host pc.
This eventually seems to conflict with two servers requesting one port 9443 on your pc.\


Referring to the configuration below of fabric-2.3/sampleconfig, you can see that each port 9443 is assigned to the server. Assigning one of them to the other port solves this.

fabric-2.3/sampleconfig/orderer.yaml

configuration of orderer

# orderer.yaml
...
Admin:
    # host and port for the admin server
    ListenAddress: 127.0.0.1:9443
...

fabric-2.3/sampleconfig/core.yaml

configuration of peer

# core.yaml
...
operations:
    # host and port for the operations server
    # listenAddress: 127.0.0.1:9443
    listenAddress: 127.0.0.1:10443
...
myeongkil kim
  • 2,465
  • 4
  • 16
  • 22
  • Yes, it works. Thank you. But other ports get conflict too. Do you know how to run the orderer and peer processes in two docker containers? Thanks for your help. – Jennie Tsai Dec 22 '20 at 01:42
  • When dealing with multiple containers, it is recommended to build a network through docker-compose. The same can be applied to the fabric, and if it is built through a container, only the port conflict on the host PC and the different network topology need to be considered. See the fabric's official sample here. [fabric-samples/docker-compose-test-net.yaml](https://github.com/hyperledger/fabric-samples/blob/master/test-network/docker/docker-compose-test-net.yaml) – myeongkil kim Dec 22 '20 at 02:24
  • Really helpful. Thanks a lot! – Jennie Tsai Dec 23 '20 at 03:22
0

This is not a direct answer to the port mapping / collision issue, but we've had great success using the new Kubernetes Test Network as a development platform running on a local system with a virtual Kubernetes cluster running in KIND (Kubernetes in Docker).

In this mode, applications can be developed using the Gateway client (exposed via a port forward or ingress), and smart contracts running As a Service can be launched either in the cluster OR run on the local host OS in a container, binary, or launched in a debugger.

The documentation for the development setup is still sparse, but we'd love to hear feedback on the overall approach, as it offers an exponentially better experience for working with a test network in a development context. In general the process of "port juggling" with Compose is no longer relevant when working on a local Kubernetes cluster. In this mode, you can run services on the host network, instructing peers/orderers/etc. to connect to the remote process running on the host OS.

Josh
  • 22
  • 2