Jafeyyu commented on issue #2546:
URL: https://github.com/apache/dubbo-go/issues/2546#issuecomment-1869283075

   进一步调试发现,在hessian.go中的marshalRequest方法中,对时间做了处理
   ```go
   func marshalRequest(encoder *hessian.Encoder, p DubboPackage) ([]byte, 
error) {
        service := p.Service
        request := EnsureRequestPayload(p.Body)
        _ = encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION)
        _ = encoder.Encode(service.Path)
        _ = encoder.Encode(service.Version)
        _ = encoder.Encode(service.Method)
   
        args, ok := request.Params.([]interface{})
   
        if !ok {
                logger.Infof("request args are: %+v", request.Params)
                return nil, perrors.Errorf("@params is not of type: 
[]interface{}")
        }
        types, err := GetArgsTypeList(args)
        if err != nil {
                return nil, perrors.Wrapf(err, " PackRequest(args:%+v)", args)
        }
        _ = encoder.Encode(types)
        for _, v := range args {
                _ = encoder.Encode(v)
        }
   
        request.Attachments[PATH_KEY] = service.Path
        request.Attachments[VERSION_KEY] = service.Version
        if len(service.Group) > 0 {
                request.Attachments[GROUP_KEY] = service.Group
        }
        if len(service.Interface) > 0 {
                request.Attachments[INTERFACE_KEY] = service.Interface
        }
        if service.Timeout != 0 {
                request.Attachments[TIMEOUT_KEY] = 
strconv.Itoa(int(service.Timeout / time.Millisecond))
        }
   
        err = encoder.Encode(request.Attachments)
        return encoder.Buffer(), err
   }
   ```
   
当timeout不等于0时,将timeout除以了time.Millisecond,但是在dubbo_invoker.go的getTimeout中,已经将时间处理成存入到attachment中
   ```
   // get timeout including methodConfig
   func (di *DubboInvoker) getTimeout(ivc *invocation.RPCInvocation) 
time.Duration {
        methodName := ivc.MethodName()
        if di.GetURL().GetParamBool(constant.GenericKey, false) {
                methodName = ivc.Arguments()[0].(string)
        }
        timeout := 
di.GetURL().GetParam(strings.Join([]string{constant.MethodKeys, methodName, 
constant.TimeoutKey}, "."), "")
        if len(timeout) != 0 {
                if t, err := time.ParseDuration(timeout); err == nil {
                        // config timeout into attachment
                        ivc.SetAttachment(constant.TimeoutKey, 
strconv.Itoa(int(t.Milliseconds()))) // 
已经将timeout处理成毫秒存入attachment,应该将.Milliseconds()换成.Nanoseconds()
                        return t
                }
        }
        // set timeout into invocation at method level
        ivc.SetAttachment(constant.TimeoutKey, 
strconv.Itoa(int(di.timeout.Milliseconds())))  // 
已经将timeout处理成毫秒存入attachment,应该将.Milliseconds()换成.Nanoseconds()
        return di.timeout
   }
   ```
   
最终导致timeout被缩小了1000000倍,变成了0,将上述方法中的两处Milliseconds()更改成Nanoseconds(),测试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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to