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

why does timout invalid? #502

Open
WesleyBlq opened this issue Mar 21, 2023 · 2 comments
Open

why does timout invalid? #502

WesleyBlq opened this issue Mar 21, 2023 · 2 comments

Comments

@WesleyBlq
Copy link

I am using grpc-web and have set the timeout options, but they do not seem to be working. I am unsure of the reason for this error. Can you help me identify the issue?

import { ArMockClient } from "@/infra/proto/ar_mock.client";
import { Empty } from "@/infra/proto/google/protobuf/empty";
import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport";
import { logger } from "@/utils/logger";

class GRPCClient {
  constructor() {
    this.client = new ArMockClient(
      new GrpcWebFetchTransport({
        baseUrl: "http://192.168.10.210:8509",
        // timeout: 2000,
      })
    );
  }

  async GetArMockData() {
    logger.info("GetArMockData start");
    try {
      logger.info("GetArMockData start");
      const { response } = await this.client.getArMockData(Empty.create(), {
        timeout: 2000,
      });
      logger.info("GetArMockData end");
      return [...response.graphic.locations, ...response.graphic.polygons];
    } catch (e) {
      throw new Error("GetArMockData error");
    }
  }
}

export const grpcClient = new GRPCClient();
@northsea4
Copy link

I am facing a similar issue where configuring the timeout parameter in either GrpcWebFetchTransport or the service method itself proves ineffective. Furthermore, during my testing, I have observed that the timeout duration appears to be approximately 1.3 minutes (though this time estimate might be influenced by my current environment).

@jcready
Copy link
Contributor

jcready commented Aug 4, 2023

The timeout/deadline is simply sent as a request header to the server. There is no setTimeout being used client-side. The issue would be with the server not respecting the grpc-timeout request header (the server likely has its own timeout which is shorter than what you specified).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants