Sponsor: set gRPC client idle timeout (#30913)
This commit is contained in:
parent
e4ddbfbe69
commit
f7b89cedc3
1 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/evcc-io/evcc/util"
|
"github.com/evcc-io/evcc/util"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
@ -29,7 +30,11 @@ func Connection() (*grpc.ClientConn, error) {
|
||||||
creds := credentials.NewTLS(&tls.Config{
|
creds := credentials.NewTLS(&tls.Config{
|
||||||
ServerName: host,
|
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
|
return conn, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue