Chaincode registration failed: container exited with 0 after committing chaincode to channel

0

My network is composed of 3 ordering nodes which are in the same orderer organization and 2 peer nodes which are in 2 peer organizations and listening on the port localhost:20000 and localhost:20001 respectively. I used the following command to commit my chaincode to the channel named channel1:

./peer lifecycle chaincode commit -o localhost:10104 --ordererTLSHostnameOverride localhost --channelID channel1 --name basic --version 1.0 --sequence 1 --tls --cafile ../../../organizations/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/tlscacerts/tls-ca-cert.pem --peerAddresses localhost:20000 --tlsRootCertFiles ../../../organizations/peerOrganizations/org1.example.com/peers/peer0.example.com/tls/ca.crt --peerAddresses localhost:20001 --tlsRootCertFiles ../../../organizations/peerOrganizations/org2.example.com/peers/peer0.example.com/tls/ca.crt
2021-04-16 15:55:30.383 CST [chaincodeCmd] ClientWait -> INFO 001 txid [988fe1654f482a670f90aac12608895a94f64e6beac3e376a54c931b602b27eb] committed with status (VALID) at localhost:20000
2021-04-16 15:55:30.385 CST [chaincodeCmd] ClientWait -> INFO 002 txid [988fe1654f482a670f90aac12608895a94f64e6beac3e376a54c931b602b27eb] committed with status (VALID) at localhost:20001

But the peer log showed that it failed to launch the chaincode

2021-04-16 15:55:38.224 CST [lifecycle] Work -> WARN 05a could not launch chaincode 'basic_1.0:6116f8e8a64858d76c177dda4143f235820e3f029a81ac39924b60269b6f931c': chaincode registration failed: container exited with 0

And the 2 chaincode container logs showed it failed to connect with the corresponding chaincodeListening Addresss 127.0.0.1:20100 and 127.0.0.1:20101.

In [core.yaml], chaincodeListening Address is configured as follows:

    # The endpoint this peer uses to listen for inbound chaincode connections.
    # If this is commented-out, the listen address is selected to be
    # the peer's address (see below) with port 7052
    chaincodeListenAddress: 0.0.0.0:20100

    # The endpoint the chaincode for this peer uses to connect to the peer.
    # If this is not specified, the chaincodeListenAddress address is selected.
    # And if chaincodeListenAddress is not specified, address is selected from
    # peer address (see below). If specified peer address is invalid then it
    # will fallback to the auto detected IP (local IP) regardless of the peer
    # addressAutoDetect value.
    chaincodeAddress: localhost:20100
    # The endpoint this peer uses to listen for inbound chaincode connections.
    # If this is commented-out, the listen address is selected to be
    # the peer's address (see below) with port 7052
    chaincodeListenAddress: 0.0.0.0:20101

    # The endpoint the chaincode for this peer uses to connect to the peer.
    # If this is not specified, the chaincodeListenAddress address is selected.
    # And if chaincodeListenAddress is not specified, address is selected from
    # peer address (see below). If specified peer address is invalid then it
    # will fallback to the auto detected IP (local IP) regardless of the peer
    # addressAutoDetect value.
    chaincodeAddress: localhost:20101
$ netstat -vanp tcp | grep 20100
tcp46      0      0  *.20100                *.*                    LISTEN      131072 131072  33202      0 0x0100 0x00000026
$ netstat -vanp tcp | grep 20101
tcp46      0      0  *.20101                *.*                    LISTEN      131072 131072  33495      0 0x0100 0x00000026

The peer2 chaincode container logs are as following:

Thread[grpc-default-executor-1,5,main] 07:55:37:757 SEVERE  org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$1 onError                Last txid=null An error occurred on the chaincode stream. Shutting down the chaincode stream.UNAVAILABLE: io exception
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
    at io.grpc.Status.asRuntimeException(Status.java:533)
    at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:478)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:434)
    at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:763)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:742)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:20101
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.grpc.netty.shaded.io.netty.channel.unix.Errors.throwConnectException(Errors.java:124)
    at io.grpc.netty.shaded.io.netty.channel.unix.Socket.finishConnect(Socket.java:243)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:672)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:649)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:529)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:465)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
    at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)
.. caused by ..
finishConnect(..) failed: Connection refused: localhost/127.0.0.1:20101
io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:20101
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.grpc.netty.shaded.io.netty.channel.unix.Errors.throwConnectException(Errors.java:124)
    at io.grpc.netty.shaded.io.netty.channel.unix.Socket.finishConnect(Socket.java:243)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:672)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:649)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:529)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:465)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
    at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)
.. caused by ..
finishConnect(..) failed: Connection refused
java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.grpc.netty.shaded.io.netty.channel.unix.Errors.throwConnectException(Errors.java:124)
    at io.grpc.netty.shaded.io.netty.channel.unix.Socket.finishConnect(Socket.java:243)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:672)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:649)
    at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:529)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:465)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
    at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)

How could I solve the problem?:/

hyperledger-fabric
hyperledger
asked on Stack Overflow Apr 16, 2021 by Yi Wei • edited Apr 16, 2021 by Yi Wei

1 Answer

0

The error is caused by running peer outside Docker and chaincode container inside Docker. So [localhost] is the local IP address of the Docker virtual machine instead of the local IP address of my laptop. The most direct solution is running both of them in Docker.

answered on Stack Overflow Apr 20, 2021 by Yi Wei

User contributions licensed under CC BY-SA 3.0