From 0498bcf30c8d5510f3327d7dfd513dec951f75ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 12 Sep 2022 21:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4GRPC=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/task_sync_api_nodes.go | 3 ++- internal/rpc/rpc_client.go | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/nodes/task_sync_api_nodes.go b/internal/nodes/task_sync_api_nodes.go index 8d590cb..e167fbb 100644 --- a/internal/nodes/task_sync_api_nodes.go +++ b/internal/nodes/task_sync_api_nodes.go @@ -13,6 +13,7 @@ import ( "github.com/iwind/TeaGo/logs" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "net/url" "sort" "strings" @@ -152,7 +153,7 @@ func (this *SyncAPINodesTask) testEndpoints(endpoints []string) bool { }() var conn *grpc.ClientConn if u.Scheme == "http" { - conn, err = grpc.DialContext(ctx, u.Host, grpc.WithInsecure(), grpc.WithBlock()) + conn, err = grpc.DialContext(ctx, u.Host, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) } else if u.Scheme == "https" { conn, err = grpc.DialContext(ctx, u.Host, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ InsecureSkipVerify: true, diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index ce1ea3a..3cadeac 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -167,10 +167,13 @@ func (this *RPCClient) init() error { return errors.New("parse endpoint failed: " + err.Error()) } var conn *grpc.ClientConn - var callOptions = grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(128*1024*1024), - grpc.UseCompressor(gzip.Name)) + var callOptions = grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(128*1024*1024), + grpc.MaxCallSendMsgSize(128*1024*1024), + grpc.UseCompressor(gzip.Name), + ) if u.Scheme == "http" { - conn, err = grpc.Dial(u.Host, grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err = grpc.Dial(u.Host, grpc.WithTransportCredentials(insecure.NewCredentials()), callOptions) } else if u.Scheme == "https" { conn, err = grpc.Dial(u.Host, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ InsecureSkipVerify: true,