You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/03/28 03:46:13 UTC

[GitHub] [dubbo-go] kzhan opened a new pull request #1111: fix: grpc dial connect timeout 3.0

kzhan opened a new pull request #1111:
URL: https://github.com/apache/dubbo-go/pull/1111


   补充 grpc dial connect timeout;
   为了生产环境的稳定安全考虑,失败返回nil并且给出相应告警,panic对生产运行中程序可能会造成毁灭性代价


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks closed pull request #1111: fix: grpc dial connect timeout 3.0

Posted by GitBox <gi...@apache.org>.
AlexStocks closed pull request #1111:
URL: https://github.com/apache/dubbo-go/pull/1111


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] kzhan commented on a change in pull request #1111: fix: grpc dial connect timeout 3.0

Posted by GitBox <gi...@apache.org>.
kzhan commented on a change in pull request #1111:
URL: https://github.com/apache/dubbo-go/pull/1111#discussion_r603849626



##########
File path: protocol/grpc/client.go
##########
@@ -90,20 +91,30 @@ type Client struct {
 }
 
 // NewClient creates a new gRPC client.
-func NewClient(url *common.URL) *Client {
+func NewClient(url *common.URL) (*Client, error) {
 	// if global trace instance was set , it means trace function enabled. If not , will return Nooptracer
 	tracer := opentracing.GlobalTracer()
 	dialOpts := make([]grpc.DialOption, 0, 4)
 	maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
-	dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithUnaryInterceptor(
-		otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())),
+
+	//consumer config client connectTimeout
+	connectTimeout := config.GetConsumerConfig().ConnectTimeout
+
+	dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(connectTimeout),
+		grpc.WithUnaryInterceptor(
+			otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())),
 		grpc.WithDefaultCallOptions(
 			grpc.CallContentSubtype(clientConf.ContentSubType),
 			grpc.MaxCallRecvMsgSize(1024*1024*maxMessageSize),
 			grpc.MaxCallSendMsgSize(1024*1024*maxMessageSize)))
+
+	logger.Infof("begin grpc dial:%s, begin time: %s ", url, time.Now().Format("2006-01-02 15:04:05.000"))
 	conn, err := grpc.Dial(url.Location, dialOpts...)
+	logger.Infof("end grpc dial:%s, end time: %s", url, time.Now().Format("2006-01-02 15:04:05.000"))

Review comment:
       ok




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zouyx commented on a change in pull request #1111: fix: grpc dial connect timeout 3.0

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #1111:
URL: https://github.com/apache/dubbo-go/pull/1111#discussion_r602993268



##########
File path: protocol/grpc/client.go
##########
@@ -90,20 +91,30 @@ type Client struct {
 }
 
 // NewClient creates a new gRPC client.
-func NewClient(url *common.URL) *Client {
+func NewClient(url *common.URL) (*Client, error) {
 	// if global trace instance was set , it means trace function enabled. If not , will return Nooptracer
 	tracer := opentracing.GlobalTracer()
 	dialOpts := make([]grpc.DialOption, 0, 4)
 	maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
-	dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithUnaryInterceptor(
-		otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())),
+
+	//consumer config client connectTimeout
+	connectTimeout := config.GetConsumerConfig().ConnectTimeout
+
+	dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(connectTimeout),
+		grpc.WithUnaryInterceptor(
+			otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())),
 		grpc.WithDefaultCallOptions(
 			grpc.CallContentSubtype(clientConf.ContentSubType),
 			grpc.MaxCallRecvMsgSize(1024*1024*maxMessageSize),
 			grpc.MaxCallSendMsgSize(1024*1024*maxMessageSize)))
+
+	logger.Infof("begin grpc dial:%s, begin time: %s ", url, time.Now().Format("2006-01-02 15:04:05.000"))
 	conn, err := grpc.Dial(url.Location, dialOpts...)
+	logger.Infof("end grpc dial:%s, end time: %s", url, time.Now().Format("2006-01-02 15:04:05.000"))

Review comment:
       you can use tracing for process time around the request,why do you add this log?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org