Closed maverick-zhn closed 4 years ago
which step are you getting this error from? When you try to register a user?
This is usually because of a problem in this step - i.e. downloading and importing the connection profile. If you see that all of your peers have a green square at the top of them, that means they are running. If your peer is not in the running state, then delete the peer and re-create that component.
Otherwise, make sure you downloaded the connection profile, renamed it ibpConnection.json
and saved it in this directory. This is because config.json is using this file to send transactions to the peers on your cloud service which are created from your Kubernetes Cluster.
Let me know if this solves it...
:)
@maverick-zhn
Do not think the problem will be from the anchor peer. Check this video at around minute 8, which will show how to download the connection profile, what it looks like, and how to ensure that you are sending your transaction to the peers.
@horeaporutiu thanks for your help.
I did generate the connection profile: ibpConnection.js
file from the instantiated smart-contract in the Fabric in IBM Cloud. However, I get this:
userName:
app-admin
wallet:
FileSystemWallet {
storesInitialized: false,
walletMixin: X509WalletMixin {},
path:
'/Users/username/repos/blockchain/evote/web-app/server/wallet' }
ccp:
{ name: 'mychannel',
description: 'Network on IBP v2',
version: '1.0.0',
client: { organization: 'votermsp' },
organizations:
{ ownermsp:
{ mspid: 'votermsp',
peers: [Array],
certificateAuthorities: [Array] } },
orderers:
{ 'ip_address:31300':
{ url: 'grpcs://ip_address:31300', tlsCACerts: [Object] } },
peers:
{ 'ip_address:32424':
{ url: 'grpcs://ip_address:32424',
tlsCACerts: [Object],
grpcOptions: [Object] } },
certificateAuthorities:
{ 'ip_address:30396':
{ url: 'https://ip_address:30396',
caName: 'ca',
tlsCACerts: [Object] } } }
before gateway.connect:
2020-03-13T21:06:26.764Z - error: [Network]: _initializeInternalChannel: no suitable peers available to initialize from
I added one async function in the app.js (this function is the first thing to run):
async function test() {
let networkObj = await network.connectToNetwork(appAdmin);
let response = await network.invoke(networkObj, true, 'queryAll', '');
let parsedResponse = await JSON.parse(response);
console.log(parseResponse);
}
I did make some changes to fit my application, however, the network and configuration resemble your example.
I have also run the enrollAdmin.js
script.
Apparently, it works for the localhost configuration and fabric.
@maverick-zhn so since you are enrolling the admin and you should see the following in the terminal
msg: Successfully enrolled admin user app-admin and imported it into the wallet
You should be connecting to the network with app-admin
. I see in your code you are using admin
which works for the local version, but not the cloud version.
I.e. in your wallet you should have a folder with app-admin, and the public and private key for that identity and you need to connect to the network with those identities.
Does that make sense?
Also - could you attach what your config.json looks like and what you wallet looks like?
@horeaporutiu, thank you.
This is the config.json:
{
"connection_file": "ibpConnection.json",
"appAdmin": "app-admin",
"appAdminSecret": "app-adminpw",
"orgMSPID": "votermsp",
"caName": "https://ip-address:30396",
"userName": "V1",
"gatewayDiscovery": { "enabled": true, "asLocalhost": false }
}
For the wallet, it has one directory app-admin that includes the public and private key. It works nicely with a fabric in my localhost. I am doing tests with that, then I will migrate code and data to the cloud.
Thanks again.
@maverick-zhn
Looks like it is getting an error at the let networkObj = await network.connectToNetwork(appAdmin);
which is taking in your wallet, userName, and gateway options. Since your gateway options look fine ( you can print them out before the call to be sure) but the only other thing that is possibly wrong is the connection profile itself, either that or the network and the kubernetes components are down.
Could you try refreshing the cluster within the blockchain platform service in IBM Cloud? as shown below
After it is refreshed, make sure that all the components in the network have a green status box and show that they are running, then try and run the script again.
any update on this? @maverick-zhn
@horeaporutiu, My free-cluster just expired. I will need to create another one. I was able to run the network locally though. I will create another IBM Cloud Cluster this weekend. Thank you for your help.
I got this error when querying the fabric network:
Do I need anchor peers? I have the Voter Peer as the anchor. Can you please recommend a solution for this? I followed your instructions on how to create a free cluster and how to deploy a Fabric Network.
Thank you in advance.