You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "578157900 (via GitHub)" <gi...@apache.org> on 2023/04/14 03:31:16 UTC

[GitHub] [dubbo-go] 578157900 opened a new issue, #2302: restful protocol transport dial cause io timeout

578157900 opened a new issue, #2302:
URL: https://github.com/apache/dubbo-go/issues/2302

   ### Environment
   
   <!-- 
   - Server: Dubbo-go, v3.0.5
   - Client: Dubbo-go, v3.0.5
   - Protocol: Triple
   - Registry: Nacos, v2.0.0
   -->
   
   - Client: Dubbo-go, v1.5.9
   - Protocol: rest
   - Registry: zookeeper
   
   ### Issue description
   
   <!-- Here is a brief description about the issue. -->
   https://github.com/apache/dubbo-go/blob/main/protocol/rest/client/client_impl/resty_client.go#L59
   `
   DialContext: func(_ context.Context, network, addr string) (net.Conn, error) {
   				c, err := net.DialTimeout(network, addr, restOption.ConnectTimeout)
   				if err != nil {
   					return nil, err
   				}
   				err = c.SetDeadline(time.Now().Add(restOption.RequestTimeout))
   				if err != nil {
   					return nil, err
   				}
   				return c, nil
   },
   `
   http连接池复用tcp连接时,因为设置了deadline,resp未返回直接抛出io timeout。


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

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] 578157900 commented on issue #2302: restful protocol transport dial cause io timeout

Posted by "578157900 (via GitHub)" <gi...@apache.org>.
578157900 commented on issue #2302:
URL: https://github.com/apache/dubbo-go/issues/2302#issuecomment-1507880268

   `
   func NewRestyClient(restOption *client.RestOptions) client.RestClient {
   	client := resty.New()
   	client.SetTransport(
   		&http.Transport{
   			DialContext: (&net.Dialer{
   				Timeout: restOption.ConnectTimeout,
   			}).DialContext,
   			IdleConnTimeout: 90 * time.Second,
   		}).SetTimeout(restOption.RequestTimeout)
   	return &RestyClient{
   		client: client,
   	}
   }
   `
   1. 通过配置IdleConnTimeout超时来回收空闲链接。
   2. 通过client.SetTimeout来设置每次请求的超时时间。


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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