我正在写一个 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)