diff --git a/go/common/grpc/proxy/proxy.go b/go/common/grpc/proxy/proxy.go index e497b4d6403..b8ce38296bd 100644 --- a/go/common/grpc/proxy/proxy.go +++ b/go/common/grpc/proxy/proxy.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/connectivity" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" @@ -74,6 +75,12 @@ func (p *proxy) handler(srv interface{}, stream grpc.ServerStream) error { // Pass subject header upstream. upstreamCtx = metadata.AppendToOutgoingContext(upstreamCtx, policy.ForwardedSubjectMD, sub) + // Check if upstream connection was disconnected. + if p.upstreamConn != nil && p.upstreamConn.GetState() == connectivity.Shutdown { + // We need to redial if the connection was shut down. + p.upstreamConn = nil + } + // Dial upstream if necessary. if p.upstreamConn == nil { var grr error