I am creating a DApp on the Hedera Blockchain using Hedera-sdk-py, a python wrapper of Hedera SDK in Java. I keep getting JVM exception occurred: exceeded maximum attempts for request with the last exception being com.hedera.hashgraph.sdk.MaxAttemptsExceededException each time I try to create an account. The error occurs at: resp = tran.setKey(newPublicKey).setInitialBalance(Hbar(2)).execute(client). Any help will be appreciated as I have tried repeatedly without success to fix it.
from hedera import (
Hbar,
PrivateKey,
AccountCreateTransaction,
)
from get_client import client
# Generate a Ed25519 private, public key pair
newKey = PrivateKey.generate()
newPublicKey = newKey.getPublicKey()
print("private key = ", newKey.toString())
print("public key = ", newPublicKey.toString())
tran = AccountCreateTransaction()
# need a certain number of hbars, otherwise it can not be deleted later
resp = tran.setKey(newPublicKey).setInitialBalance(Hbar(2)).execute(client)
receipt = resp.getReceipt(client)
print("account = ", receipt.accountId.toString()
It sounds like the SDK is attempting to send your request to a node that's currently unavailable (see hedera status page), or your connectivity to the Hedera network is failing altogether.
Note that calls to the Hedera API are made over port 50211 (or 50212) which are sometimes blocked by enterprise firewalls, if the same code works over a cellular/mobile connection or another wifi (home/other), this is the likely cause of the problem.