Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg.Unmarshal(len(@data):0) = error:get wrong attachments #1583

Closed
PhilYue opened this issue Nov 11, 2021 · 3 comments
Closed

pkg.Unmarshal(len(@data):0) = error:get wrong attachments #1583

PhilYue opened this issue Nov 11, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@PhilYue
Copy link
Member

PhilYue commented Nov 11, 2021

What happened:

基于 JSON-PRC 改造入参出参,同 #1582 ,在此代码基础上,Server 同时暴露 dubbojsonrpc协议,Client 消费使用 dubbo协议时,Server 报错如下:

Server Error Log:

2021-11-11T15:14:28.086+0800    ERROR   dubbo/dubbo_codec.go:196        pkg.Unmarshal(len(@data):0) = error:get wrong attachments: 
dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl.unmarshalRequestBody
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/impl/hessian.go:267
dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl.HessianSerializer.Unmarshal
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/impl/hessian.go:56
dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl.(*ProtocolCodec).Decode
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/impl/codec.go:186
dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl.(*DubboPackage).Unmarshal
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/impl/package.go:93
dubbo.apache.org/dubbo-go/v3/protocol/dubbo.(*DubboCodec).decodeRequest
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/dubbo_codec.go:189
dubbo.apache.org/dubbo-go/v3/protocol/dubbo.(*DubboCodec).Decode
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/dubbo_codec.go:165
dubbo.apache.org/dubbo-go/v3/remoting/getty.(*RpcServerPackageHandler).Read
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/remoting/getty/readwriter.go:104
github.com/apache/dubbo-getty.(*session).handleTCPPackage
        /Users/phil/go/pkg/mod/github.com/apache/dubbo-getty@v1.4.5/session.go:627
github.com/apache/dubbo-getty.(*session).handlePackage
        /Users/phil/go/pkg/mod/github.com/apache/dubbo-getty@v1.4.5/session.go:549
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1371
dubbo.apache.org/dubbo-go/v3/protocol/dubbo.(*DubboCodec).decodeRequest
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/dubbo_codec.go:196
dubbo.apache.org/dubbo-go/v3/protocol/dubbo.(*DubboCodec).Decode
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/dubbo/dubbo_codec.go:165
dubbo.apache.org/dubbo-go/v3/remoting/getty.(*RpcServerPackageHandler).Read
        /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/remoting/getty/readwriter.go:104
github.com/apache/dubbo-getty.(*session).handleTCPPackage
        /Users/phil/go/pkg/mod/github.com/apache/dubbo-getty@v1.4.5/session.go:627
github.com/apache/dubbo-getty.(*session).handlePackage
        /Users/phil/go/pkg/mod/github.com/apache/dubbo-getty@v1.4.5/session.go:549

Client dubbogo.yml

dubbo:
  consumer:
    references:
      UserProvider:
#        protocol: jsonrpc
        protocol: dubbo
        interface: com.ikurento.user.UserProvider

What you expected to happen:
Server正常处理请求

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

@PhilYue
Copy link
Member Author

PhilYue commented Nov 11, 2021

@PhilYue

@PhilYue
Copy link
Member Author

PhilYue commented Nov 11, 2021

dubbo-go/protocol/dubbo/impl/hessian.go#unmarshalRequestBody

        attachments, err := decoder.Decode()
	if err != nil {
		return perrors.WithStack(err)
	}

	//if attachments == nil {
	if attachments == nil || attachments == "" { // || attachments == ""
		attachments = map[interface{}]interface{}{constant.InterfaceKey: target}
	}

	if v, ok := attachments.(map[interface{}]interface{}); ok {
		v[DUBBO_VERSION_KEY] = dubboVersion
		req[6] = ToMapStringInterface(v)
		buildServerSidePackageBody(p)
		return nil
	}
	return perrors.Errorf("get wrong attachments: %+v", attachments)

@AlexStocks
Copy link
Contributor

try to fix it by yourself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants