Home > Backend Development > Golang > Increase gRPC timeout in Go

Increase gRPC timeout in Go

WBOY
Release: 2024-02-06 08:00:13
forward
623 people have browsed it

增加 Go 中的 gRPC 超时

Question content

There are some gRPC calls that require the connection to stay connected for more than 5 minutes, and the connection will be idle until the operation is completed.

I tried keepalive settings and even context.WithTimeout() but the gRPC connection times out after 5 minutes (code = unknown desc = stream timeout")

How to increase the idle timeout for such gRPC calls?


Correct answer


Have you tried it

clientDeadline := time.Now().Add(time.Duration(*deadlineMs) * time.Millisecond)
ctx, cancel := context.WithDeadline(ctx, clientDeadline)
Copy after login

Similar to the definition in the official grpc documentation. This is the https://www.php.cn/link/491723c615d42eb8b44650bcbe384561 link.

The above is the detailed content of Increase gRPC timeout in Go. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template