Home > Backend Development > Golang > Why is my Dgraph connection failing with 'connection closed before server preface received'?

Why is my Dgraph connection failing with 'connection closed before server preface received'?

Linda Hamilton
Release: 2024-12-19 09:42:09
Original
750 people have browsed it

Why is my Dgraph connection failing with

Unable to Connect to Dgraph: Resolving ""Connection Closed Before Server Preface Received"" Error

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
Copy after login

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)
Copy after login

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!

source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template