wangchuanjin il y a 1 mois
Parent
commit
93da71d44a
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6 6
      client.go

+ 6 - 6
client.go

@@ -7,6 +7,7 @@ import (
 	"encoding/json"
 	"errors"
 	"google.golang.org/grpc"
+	"google.golang.org/grpc/keepalive"
 	"io"
 	"jygit.jydev.jianyu360.cn/BaseService/ossClient/constant"
 	"jygit.jydev.jianyu360.cn/BaseService/ossClient/entity"
@@ -252,12 +253,11 @@ func RpcCall(address, serviceMethod string, args any, reply any) error {
 func GrpcCall(address string, timeout int64) (pb.ServiceClient, context.Context, func(), error) {
 	var err error
 	GrpcCoonOnce.Do(func() {
-		//GrpcCoon, err = grpc.Dial(address, grpc.WithInsecure(), grpc.WithKeepaliveParams(keepalive.ClientParameters{
-		//	Time:                10 * time.Second, // 发送ping的间隔
-		//	Timeout:             5 * time.Second,  // 等待pong响应的超时时间
-		//	PermitWithoutStream: true,             // 是否在没有活跃流的情况下发送pings
-		//}))
-		GrpcCoon, err = grpc.Dial(address, grpc.WithInsecure())
+		GrpcCoon, err = grpc.Dial(address, grpc.WithInsecure(), grpc.WithKeepaliveParams(keepalive.ClientParameters{
+			Time:                10 * time.Second, // 发送ping的间隔
+			Timeout:             5 * time.Second,  // 等待pong响应的超时时间
+			PermitWithoutStream: true,             // 是否在没有活跃流的情况下发送pings
+		}))
 	})
 	var cancel context.CancelFunc
 	if err != nil {