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

call Requset Timeout with detail <nil> #2694

Closed
kanrin opened this issue Mar 5, 2024 · 2 comments
Closed

call Requset Timeout with detail <nil> #2694

kanrin opened this issue Mar 5, 2024 · 2 comments

Comments

@kanrin
Copy link

kanrin commented Mar 5, 2024

I'll call a client, but occasionally the request times out, but the information in the detail is
my log
Retrying request. Previous attempt failed with: {"id":"go.micro.client","code":408,"detail":"\u003cnil\u003e","status":"Request Timeout"}
This doesn't happen often, but it does happen occasionally

@kanrin
Copy link
Author

kanrin commented Mar 5, 2024

use go-micro
"go-micro.dev/v4"

and client code

func Call(ctx context.Context, service *ServiceName, endpoint string, req any) error {
	c := client.NewClient(client.WithLogger(NewRpcLog()))
	if !service.Valid() {
		return fmt.Errorf("no valid service: %+v", service)
	}
	s, err := RandomGetService(service)
	if err != nil {
		return fmt.Errorf("get service error: %s", err)
	}
	rsp := new(message.Empty)
	if err := c.Call(ctx, c.NewRequest(s.Name, endpoint, req), rsp, client.WithRetries(0), client.WithRequestTimeout(time.Minute)); err != nil {
		return fmt.Errorf("call client:%s error:%s", s.Name, err)
	}
	if rsp.Count != 1 {
		klog.Debugf("rsp:%+v", rsp)
		return nil
	}
	return nil
}

empty struct such as

type Empty struct {
	Count int `json:"count"`
}

@asim
Copy link
Member

asim commented Jul 12, 2024

Try setting retries higher than 0. Otherwise assuming stale entries in the registry, in which case you may want to try restart that or clear it out of stale entries, or use the TTL and heartbeat configuration.

@asim asim closed this as completed Jul 12, 2024
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

2 participants