小编noo*_*dev的帖子

Golang gRPC 连接客户端错误 - “错误读取服务器前言:http2:框架太大”

我正在写一个 go 客户端来消费

conn, err := grpc.DialContext(ctx, serverAddr, grpc.WithBlock(), grpc.WithReturnConnectionError(), getTransportCredential(false))
Run Code Online (Sandbox Code Playgroud)

上面的调用挂起直到上下文超时并返回以下错误

failed to dial: context deadline exceeded: connection error: desc = "error reading server preface: http2: frame too large"
Run Code Online (Sandbox Code Playgroud)

getTransportCredential(insecure bool)定义如下

func getTransportCredential(insecure bool) grpc.DialOption {
    if insecure {
        return grpc.WithTransportCredentials(insecure2.NewCredentials())
    }

    rootCAs, err := x509.SystemCertPool()
    if err != nil {
        panic(err)
    }
    if rootCAs == nil {
        fmt.Println("SystemCertPool is nil")
        rootCAs = x509.NewCertPool()
    }

    caCert := `-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----`

    if caCert != "" {
        // Append …
Run Code Online (Sandbox Code Playgroud)

go google-cloud-platform http2 grpc google-cloud-run

6
推荐指数
1
解决办法
1万
查看次数