apache / dubbo-go

Go Implementation For Apache Dubbo .
https://dubbo.apache.org/
Apache License 2.0
4.73k stars 929 forks source link

调用java服务报错reflect: call of reflect.Value.MethodByName on zero Value #2403

Open ssfyn opened 1 year ago

ssfyn commented 1 year ago

问题

错误讯息

panic: reflect: call of reflect.Value.MethodByName on zero Value

goroutine 130 [running]:
reflect.Value.MethodByName({0x0?, 0x0?, 0x1400066ad58?}, {0x103d55724?, 0x14000181740?})
    /usr/local/go/src/reflect/value.go:2026 +0x114
github.com/dubbogo/triple/pkg/triple.getInvoker({0x0?, 0x0?}, 0x15?)
    /Users/me/go/pkg/mod/github.com/dubbogo/triple@v1.2.2-rc3/pkg/triple/dubbo3_conn.go:79 +0x194
github.com/dubbogo/triple/pkg/triple.NewTripleClient({0x0, 0x0}, 0x6?)
    /Users/me/go/pkg/mod/github.com/dubbogo/triple@v1.2.2-rc3/pkg/triple/dubbo3_client.go:117 +0x764
dubbo.apache.org/dubbo-go/v3/protocol/dubbo3.NewDubboInvoker(0x1400053e300)
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/protocol/dubbo3/dubbo3_invoker.go:128 +0x898
dubbo.apache.org/dubbo-go/v3/protocol/dubbo3.(*DubboProtocol).Refer(0x14000346580, 0x1400053e300)
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/protocol/dubbo3/dubbo3_protocol.go:137 +0x28
dubbo.apache.org/dubbo-go/v3/metadata/service/local.createProxy({0x10454de80?, 0x1400069a8c0})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/metadata/service/local/metadata_service_proxy_factory.go:69 +0x128
dubbo.apache.org/dubbo-go/v3/metadata/service.(*BaseMetadataServiceProxyFactory).GetProxy(0x103d4f1e7?, {0x10454de80?, 0x1400069a8c0?})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/metadata/service/local_service.go:119 +0x34
dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.GetMetadataInfo({0x10454de80, 0x1400069a8c0}, {0x1400037cc40, 0x20})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/servicediscovery/service_instances_changed_listener_impl.go:209 +0x118
dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.(*ServiceInstancesChangedListenerImpl).OnEvent(0x140002ca360, {0x104539f60?, 0x14000376190})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/servicediscovery/service_instances_changed_listener_impl.go:91 +0x5e0
dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.(*ServiceDiscoveryRegistry).SubscribeURL(0x140001ec870, 0x14000650b40, {0x1045356f0, 0x14000650fc0}, 0x14000199200)
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/servicediscovery/service_discovery_registry.go:236 +0x56c
dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.(*ServiceMappingChangedListenerImpl).OnEvent(0x14000276080, {0x104539f90?, 0x14000791ef8?})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/servicediscovery/service_mapping_change_listener_impl.go:84 +0x13c
dubbo.apache.org/dubbo-go/v3/registry/servicediscovery.(*ServiceDiscoveryRegistry).Subscribe(0x140000a42d0, 0x14000650b40, {0x1045356f0?, 0x14000650fc0})
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/servicediscovery/service_discovery_registry.go:216 +0x2e4
dubbo.apache.org/dubbo-go/v3/registry/directory.(*RegistryDirectory).Subscribe(0x14000650fc0, 0x14000650b40)
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/directory/directory.go:107 +0xd0
created by dubbo.apache.org/dubbo-go/v3/registry/protocol.(*registryProtocol).Refer
    /Users/me/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.1.0/registry/protocol/protocol.go:164 +0x1f4
chickenlj commented 1 year ago

通过看zk内容发现go的服务的dubbo.metadata-service.url-params中proto是dubbo,但java的服务是tri,不确定和这个有没有关系。

请问使用的 dubbo-go 版本是? 3.1.0 吗?

ssfyn commented 1 year ago

通过看zk内容发现go的服务的dubbo.metadata-service.url-params中proto是dubbo,但java的服务是tri,不确定和这个有没有关系。

请问使用的 dubbo-go 版本是? 3.1.0 吗?

是的

DMwangnima commented 1 year ago

@ssfyn 可以给一份go侧的配置内容吗?

ssfyn commented 1 year ago

@ssfyn 可以给一份go侧的配置内容吗?

dubbo:
  application:
    name: go-example 
    module: example 
    organization: example
    owner: me
    environment: local
  registries:
    demoZK:
      protocol: zookeeper
      timeout: 3s
      address: 127.0.0.1:2181
      registry-type: all
  metadata-report: 
    protocol: zk 
    address: 127.0.0.1:2181
  protocols:
    triple:
      name: tri
      port: 20000
  provider:
    services:
      GreeterServerImpl:
        protocol: tri
        interface: "com.goexample.Greeter"
  consumer:
    references:
      GreeterClientImpl:
        interface:  "org.apache.dubbo.samples.tri.unary.Greeter"
        protocol: "tri"
DMwangnima commented 1 year ago

已经找到了问题链路,java侧的配置也能发一下么?

ssfyn commented 1 year ago

已经找到了问题链路,java侧的配置也能发一下么?

配置文件是这个

dubbo:
  application:
    name: dubbo-springboot-demo-provider
  protocol:
    name: tri
    port: -1
  registry:
    address: zookeeper://127.0.0.1:2181

java这块儿起的服务是直接使用的这个demo:
https://github.com/apache/dubbo-samples/tree/master/1-basic/dubbo-samples-triple-unary

FoghostCn commented 11 months ago

已经找到了问题链路,java侧的配置也能发一下么?

配置文件是这个

dubbo:
  application:
    name: dubbo-springboot-demo-provider
  protocol:
    name: tri
    port: -1
  registry:
    address: zookeeper://127.0.0.1:2181

java这块儿起的服务是直接使用的这个demo: https://github.com/apache/dubbo-samples/tree/master/1-basic/dubbo-samples-triple-unary

404 - page not found, is 3.2 branch ?

DMwangnima commented 11 months ago

已经找到了问题链路,java侧的配置也能发一下么?

配置文件是这个

dubbo:
  application:
    name: dubbo-springboot-demo-provider
  protocol:
    name: tri
    port: -1
  registry:
    address: zookeeper://127.0.0.1:2181

java这块儿起的服务是直接使用的这个demo: https://github.com/apache/dubbo-samples/tree/master/1-basic/dubbo-samples-triple-unary

404 - page not found, is 3.2 branch ?

应该是这个https://github.com/apache/dubbo-samples/tree/3.2/1-basic/dubbo-samples-triple-unary

FoghostCn commented 11 months ago

reproduced success,in dubbo-go tri depens on some stub method in generated pb.go file, just like that

func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient {
    return NewGreeterClient(cc)
}

https://github.com/dubbogo/triple/blob/df20316cdac5c5334f6cbf57bd3443cd75a4501f/pkg/triple/dubbo3_conn.go#L79

in metadata module it use low level api to invoke rpc, no pb.go file and GetDubboStub method generated https://github.com/apache/dubbo-go/blob/d204c4ef491dd22c58c4fd2e0a30e0f9d4e57715/metadata/service/local/service_proxy.go#L175-L190

in fact tri protocol not supported in metadata service rpc client

FoghostCn commented 11 months ago

@ssfyn in java server side,set dubbo.application.metadataServiceProtocol=dubbo to avoid this problem, we will fix it in next release