Sponsor: set gRPC client idle timeout (#30913)

This commit is contained in:
Michael Geers 2026-06-16 09:47:03 +02:00 • committed by GitHub
parent e4ddbfbe69
commit f7b89cedc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ import (
"crypto/tls"
_ "embed"
"net"
"time"
"github.com/evcc-io/evcc/util"
"google.golang.org/grpc"
@ -29,7 +30,11 @@ func Connection() (*grpc.ClientConn, error) {
creds := credentials.NewTLS(&tls.Config{
ServerName: host,
})
conn, err = grpc.Dial(hostport, grpc.WithTransportCredentials(creds))
// close idle connection shortly after startup auth instead of churning against the server's idle close
conn, err = grpc.NewClient(hostport,
grpc.WithTransportCredentials(creds),
grpc.WithIdleTimeout(5*time.Second),
)
return conn, err
}