Search code examples
javascriptdockerhyperledger-fabricchaincode

Access locally hosted Hyperledger Fabric from local network


I'm trying to access a locally hosted Hyperledger Fabric with the Fabric SDK. I have no problem to invoke transactions from my local machine. But when I'm trying to run a script using Fabric SDK from a different machine in the same network, I keep getting an error.

I specified my local IP address in the config.json

{
    "channel_name": "mychannel",
    "smart_contract_name": "smartcontract",
    "connection_file": "local_fabric_connection.json",
    "appAdmin": "admin",
    "appAdminSecret": "adminpw",
    "orgMSPID": "Org1MSP",
    "caName": "ipaddress:port",
    "userName": "user1",
    "gatewayDiscovery": { "enabled": true, "asLocalhost": false }
}

I also tried to use my local IP address by changing localhost to my IP address in the connection file:

"organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://ipaddress:17051"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://ipaddress:17054",
            "caName": "ca.org1.example.com"
        }
    }

Are there any different settings I have to change to access the Fabric from a different machine?

I'm developing smart contracts by using the IBM Blockchain Extension in VSCode.

When I'm running my script "query.js", I keep getting this error:

[Remote.js]: Error: Failed to connect before the deadline URL:grpc://peer0.org1.example.com:17051

Solution

  • I fixed the problem by deleting the gatewayDiscovery from the config.json