|
@@ -7,6 +7,7 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc"
|
|
|
|
+ "google.golang.org/grpc/keepalive"
|
|
"io"
|
|
"io"
|
|
"jygit.jydev.jianyu360.cn/BaseService/ossClient/constant"
|
|
"jygit.jydev.jianyu360.cn/BaseService/ossClient/constant"
|
|
"jygit.jydev.jianyu360.cn/BaseService/ossClient/entity"
|
|
"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) {
|
|
func GrpcCall(address string, timeout int64) (pb.ServiceClient, context.Context, func(), error) {
|
|
var err error
|
|
var err error
|
|
GrpcCoonOnce.Do(func() {
|
|
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
|
|
var cancel context.CancelFunc
|
|
if err != nil {
|
|
if err != nil {
|