Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guardian cannot connect to Hedera Local Node on a different host (gRPC Timeout errors) #3148

Closed
bpatrzyk opened this issue Jan 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working community

Comments

@bpatrzyk
Copy link

Problem description

I set up Hedera Local Node and Guardian using docker on two different virtual machines.

I experienced the following issue for this code revision (commit 141b80b (HEAD -> main, tag: v2.20.1, origin/main, origin/HEAD))

I configured LOCALNODE_ADDRESS in configs/.env.develop.guardian.system to point to the IP address of my Hedera VM.

HEDERA_NET="localnode"
PREUSED_HEDERA_NET="localnode"
LOCALNODE_ADDRESS="192.168.122.102"
LOCALNODE_PROTOCOL="http"
OPERATOR_ID="0.0.2"
OPERATOR_KEY="302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137"

When trying to generate operator id in the Guardian UI I was experiencing gRPC Timeout Errors.

I noticed that these errors are logged in guardian-service, worker-service-1 and worker-service-2
I did some debugging in the worker-service and I figured out that the localnode address in the Environment class (worker-service/src/api/helpers/environment.ts) is always localhost despite the fact that I set it to the correct IP address in the LOCALNODE_ADDRESS environment variable.

Further debugging showed that the localnode address is read from the queue message in the worker service (worker-service/src/api/worker.ts:239) but it is always undefined.

I looked into the guardian-service code and I saw that neither localNodeAddress nor localNodeProtocol is set in the message (see Workers.addNonRetryableTask - common/src/helpers/workers.ts:118)

I ended up adding the following piece of code to the localNodeAddress and localNodeProtocol functions and this proved to be a workaround to my problem - Guardian started connecting to Hedera properly.

        if (!task.data.localNodeAddress) {
          task.data.localNodeAddress = Environment.localNodeAddress;
        }
        if (!task.data.localNodeProtocol) {
          task.data.localNodeProtocol = Environment.localNodeProtocol;
        }

After the change these functions look as follows:

    /**
     * Add non retryable task
     * @param task
     * @param priority
     */
    public addNonRetryableTask(task: ITask, priority: number): Promise<any> {
        if (!task.dWorkers.addNonRetryableTaskata.network) {
            task.data.network = Environment.network;
        }
        if (!task.data.nodes) {
            task.data.nodes = Environment.nodes;
        }
        if (!task.data.mirrorNodes) {
            task.data.mirrorNodes = Environment.mirrorNodes;
        }
        if (!task.data.localNodeAddress) {
          task.data.localNodeAddress = Environment.localNodeAddress;
        }
        if (!task.data.localNodeProtocol) {
          task.data.localNodeProtocol = Environment.localNodeProtocol;
        }
        return this.addTask(task, priority, false);
    }

    /**
     * Add retryable task
     * @param task
     * @param priority
     * @param attempts
     */
    public addRetryableTask(task: ITask, priority: number, attempts: number = 0): Promise<any> {
        if (!task.data.network) {
            task.data.network = Environment.network;
        }
        if (!task.data.nodes) {
            task.data.nodes = Environment.nodes;
        }
        if (!task.data.mirrorNodes) {
            task.data.mirrorNodes = Environment.mirrorNodes;
        }
        if (!task.data.localNodeAddress) {
          task.data.localNodeAddress = Environment.localNodeAddress;
        }
        if (!task.data.localNodeProtocol) {
          task.data.localNodeProtocol = Environment.localNodeProtocol;
        }
        return this.addTask(task, priority, true, attempts);
    }

Could you please verify if this is a bug?

Step to reproduce

Steps to reproduce the behavior:

  1. Deploy Hedera Local Node on one host
  2. Deploy Guardian on a different host and point it to the local Hedera node by IP address
  3. Create account in Guardian and generate operator id
  4. The operation will fail with gRPC timeout error.

Expected behavior

Guardian connects to Hedera local node without additional code modifications.

@prernaadev01 prernaadev01 added bug Something isn't working community labels Jan 30, 2024
@artembuslaev artembuslaev mentioned this issue Feb 2, 2024
@prernaadev01
Copy link
Collaborator

This is fixed in 2.21 release. Thank you for raising ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

No branches or pull requests

4 participants