Despite successfully establishing a client connection, you're encountering an error when attempting to search Dgraph. The error message received is:
rpc error: code = Unavailable desc = connection closed before server preface received
This intermittent issue can be attributed to a variety of factors, but a prevalent cause is a TLS configuration discrepancy.
To address this issue, verify that TLS options are configured correctly on the client:
tlsConfig := &tls.Config{ Certificates: []tls.Certificate{myCertificate}, RootCAs: myCAPool, } tlsOpt := grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)) conn, err := grpc.DialContext(ctx, "<connection_string>", tlsOpt)
Additionally, ensure that client certificates are being used during the client connection. By adjusting the TLS configurations and ensuring proper certificate usage, you should no longer encounter the "connection closed before server preface received" error.
The above is the detailed content of Why is my Dgraph connection failing with 'connection closed before server preface received'?. For more information, please follow other related articles on the PHP Chinese website!