From 1cf7b02fea0478e92703c2af0ddb841b23b3c029 Mon Sep 17 00:00:00 2001 From: vthiruveedula <78776871+vthiruveedula@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:46:09 +0530 Subject: [PATCH] Trying to reconnect when the Grpc Client is in IDLE mode (#14) --- proto/client/gClient.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proto/client/gClient.go b/proto/client/gClient.go index dc19173..53363f0 100644 --- a/proto/client/gClient.go +++ b/proto/client/gClient.go @@ -40,6 +40,8 @@ type Nssai struct { type ConfigClient struct { Client protos.ConfigServiceClient Conn *grpc.ClientConn + Channel chan *protos.NetworkSliceResponse + Host string Version string MetadataRequested bool } @@ -70,6 +72,7 @@ func ConnectToConfigServer(host string) ConfClient { func (confClient *ConfigClient) PublishOnConfigChange(mdataFlag bool) chan *protos.NetworkSliceResponse { confClient.MetadataRequested = mdataFlag commChan := make(chan *protos.NetworkSliceResponse) + confClient.Channel = commChan go confClient.subscribeToConfigPod(commChan) return commChan } @@ -100,6 +103,7 @@ func CreateChannel(host string, timeout uint32) ConfClient { client := &ConfigClient{ Client: protos.NewConfigServiceClient(conn), Conn: conn, + Host: host, } return client @@ -166,6 +170,10 @@ func (confClient *ConfigClient) subscribeToConfigPod(commChan chan *protos.Netwo // Retry on failure continue } + } else if status == connectivity.Idle { + logger.GrpcLog.Errorf("Connectivity status idle, trying to connect again") + confClient.Conn.Connect() + continue } else { //logger.GrpcLog.Errorf("Connectivity status not ready") continue