hyperledger / fabric

Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.
https://wiki.hyperledger.org/display/fabric
Apache License 2.0
15.65k stars 8.81k forks source link

Instructions in "Running chaincode in development mode" tutorial lead to "bind: address already in use" error #3136

Open ionicsolutions opened 2 years ago

ionicsolutions commented 2 years ago

The tutorial claims that no changes need to be made to sampleconfig/core.yaml.

However, following the instructions leads to an error when starting the peer:

user@host:~/fabric$ FABRIC_LOGGING_SPEC=chaincode=debug CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 peer node start --peer-chaincodedev=true
...
Error: failed to initialize operations subsystem: listen tcp 127.0.0.1:9443: bind: address already in use

Per this StackOverflow post, this error can be fixed by changing the port the operations subsystem listens on.

jkneubuh commented 2 years ago

Hi Kilian,

This is not exactly answering your question, but may achieve a similar outcome. We've had really, really good success using the Kubernetes Test Network (fabric-samples/test-network-k8s) in concert with local development in an IDE / debugger for both chaincode and gateway client applications. In general the k8s test network does a much better job of mapping ports to Services running in the cluster, and is ideally suited for a local dev box when focusing on the newer Chaincode as a Service pattern.

We are very interested in feedback on the use of a k8s test network, chainocde-as-a-service, and gateway client as a Fabric development platform. The general idea is to set up a test network on K8s (running locally with a KIND cluster), and publish chaincode endpoints that refer back to a port bound to the local host (e.g... IntelliJ, VSCode, binaries, Docker containers, etc.) while connected to an IDE or debugger. It's still a little "fiddly" but the overall process is GREAT once it's wired up. We are still a little short on documentation for the setup, but there are some notes at:

Do let us know if this process can help with your development environment / use case... overall the documentation can be improved but in general we've seen positive outcomes when building Fabric apps on k8s and pivoting away from the Compose test network.

Happy coding!

ionicsolutions commented 2 years ago

Hi Josh, thanks for the recommendation. In principle, this seems to be exactly what I'm looking for.

Unfortunately, already executing the demo commands in the first link fails for me. The channel creation only succeeds after several attempts and querying the chaincode does not work. I only see "⚠️" as an output and the logfiles are not helpful either, so I don't know where the issue lies. Is there a way to see the full output for debugging? (At this point, I wouldn't mind to see pages and pages of script output, it would certainly help me identify the issue and understand what's going on under the hood.)

jkneubuh commented 2 years ago

Kilian the ./network script creates a verbose log in a network-debug.log file (I typically maintain a tail -f command in a separate shell to keep an eye on the verbose output.) Are there any clues in the log file? The scripts can be unreliable when run multiple times - does resetting to a "clean" slate with ./network unkind restore any order to the cluster with a second run? Also, I see what appears to be a bash shell above - is this on a Linux or OSX system? Are you by chance running on a Windows machine under WSL?

denyeart commented 2 years ago

Back to the original question... a change is proposed in https://github.com/hyperledger/fabric/pull/3134.