dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

泛化调用失败 Failed to invoke the method $invoke, No provider available for the service nacos

Open zyklonwu opened this issue 3 years ago • 16 comments
trafficstars

2022-07-22T14:11:47.525+0800 INFO config/root_config.go:129 [Config Center] Config center doesn't start 2022-07-22T14:28:00.374+0800 INFO nacos/registry.go:269 [Nacos Registry] New nacos registry with url = map[host:10.10.10.66 port:8848 protocol:nacos registry:nacos registry.group: registry.label:true registry.namespace:6666667e-c02b-4768-95d8-804de56exxxx registry.preferred:false registry.role:0 registry.timeout:60 registry.ttl:60 registry.weight:0 registry.zone: remote-client-name:dubbo.registries-nacos-10.10.10.66:8848 simplified:false] 2022-07-22T14:28:22.671+0800 INFO nacos/builder.go:139 [Nacos Client] New nacos client with config = [{Scheme: ContextPath: IpAddr:10.10.10.66 Port:8848}] 2022-07-22T14:28:22.672+0800 INFO nacos_client/nacos_client.go:79 logDir:</Users/wubo/go/workspace/awesomeProject/log> cacheDir:</Users/wubo/go/workspace/awesomeProject/cache> 2022-07-22T14:28:22.673+0800 INFO naming_client/push_receiver.go:80 udp server start, port: 55746 2022-07-22T14:30:39.226+0800 WARN directory/directory.go:89 fail to create router chain with url: nacos://:/com.sample.base.client.rpc.GrayFacade?app.version=&application=dubbo.io&async=true&bean.name=dubbo.io&cluster=failover&config.tracing=&environment=&generic=true&group=&interface=com.sample.base.client.rpc.GrayFacade&loadbalance=&metadata-type=local&module=sample&name=dubbo.io&organization=dubbo-go&owner=dubbo-go&provided-by=&reference.filter=generic%2Ccshutdown&registry.role=0&release=dubbo-golang-3.0.0&retries=&serialization=&side=consumer&sticky=false&timestamp=1658470313&version=1.0, err is: No routerFactory exits , create one please 2022-07-22T14:30:40.532+0800 INFO nacos/registry.go:124 [Nacos Registry] Registry instance with param = {Ip:10.10.10.99 Port:80 Weight:1 Enable:true Healthy:true Metadata:map[app.version: application:dubbo.io async:true bean.name:dubbo.io cluster:failover config.tracing: environment: generic:true group: interface:com.sample.base.client.rpc.GrayFacade loadbalance: metadata-type:local methods: module:sample nacos.category:consumers name:dubbo.io organization:dubbo-go owner:dubbo-go path:/com.sample.base.client.rpc.GrayFacade protocol:nacos provided-by: reference.filter:generic,cshutdown registry.role:0 release:dubbo-golang-3.0.0 retries: serialization: side:consumer sticky:false timestamp:1658470313 version:1.0] ClusterName: ServiceName:consumers:com.sample.base.client.rpc.GrayFacade:1.0: GroupName:DEFAULT_GROUP Ephemeral:true} 2022-07-22T14:30:40.532+0800 INFO naming_client/subscribe_callback.go:39 adding DEFAULT_GROUP@@providers:com.sample.base.client.rpc.GrayFacade:1.0: with to listener map 2022-07-22T14:30:40.532+0800 INFO naming_client/naming_proxy.go:54 register instance namespaceId:<6666667e-c02b-4768-95d8-804de56exxxx>,serviceName:<DEFAULT_GROUP@@consumers:com.sample.base.client.rpc.GrayFacade:1.0:> with instance:<{"valid":false,"marked":false,"instanceId":"","port":80,"ip":"10.10.10.99","weight":1,"metadata":{"app.version":"","application":"dubbo.io","async":"true","bean.name":"dubbo.io","cluster":"failover","config.tracing":"","environment":"","generic":"true","group":"","interface":"com.sample.base.client.rpc.GrayFacade","loadbalance":"","metadata-type":"local","methods":"","module":"sample","nacos.category":"consumers","name":"dubbo.io","organization":"dubbo-go","owner":"dubbo-go","path":"/com.sample.base.client.rpc.GrayFacade","protocol":"nacos","provided-by":"","reference.filter":"generic,cshutdown","registry.role":"0","release":"dubbo-golang-3.0.0","retries":"","serialization":"","side":"consumer","sticky":"false","timestamp":"1658470313","version":"1.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> 2022-07-22T14:30:40.532+0800 INFO util/common.go:94 Local IP:10.10.10.99 2022-07-22T14:30:40.598+0800 INFO naming_client/host_reactor.go:95 service not found in cache DEFAULT_GROUP@@providers:com.sample.base.client.rpc.GrayFacade:1.0: 2022-07-22T14:30:40.600+0800 INFO naming_client/beat_reactor.go:68 adding beat: <{"ip":"10.10.10.99","port":80,"weight":1,"serviceName":"DEFAULT_GROUP@@consumers:com.sample.base.client.rpc.GrayFacade:1.0:","cluster":"","metadata":{"app.version":"","application":"dubbo.io","async":"true","bean.name":"dubbo.io","cluster":"failover","config.tracing":"","environment":"","generic":"true","group":"","interface":"com.sample.base.client.rpc.GrayFacade","loadbalance":"","metadata-type":"local","methods":"","module":"sample","nacos.category":"consumers","name":"dubbo.io","organization":"dubbo-go","owner":"dubbo-go","path":"/com.sample.base.client.rpc.GrayFacade","protocol":"nacos","provided-by":"","reference.filter":"generic,cshutdown","registry.role":"0","release":"dubbo-golang-3.0.0","retries":"","serialization":"","side":"consumer","sticky":"false","timestamp":"1658470313","version":"1.0"},"scheduled":false}> to beat map 2022-07-22T14:30:57.434+0800 INFO naming_client/naming_proxy.go:103 namespaceId:<6666667e-c02b-4768-95d8-804de56exxxx> sending beat to server:<{"ip":"10.10.10.99","port":80,"weight":1,"serviceName":"DEFAULT_GROUP@@consumers:com.sample.base.client.rpc.GrayFacade:1.0:","cluster":"","metadata":{"app.version":"","application":"dubbo.io","async":"true","bean.name":"dubbo.io","cluster":"failover","config.tracing":"","environment":"","generic":"true","group":"","interface":"com.sample.base.client.rpc.GrayFacade","loadbalance":"","metadata-type":"local","methods":"","module":"sample","nacos.category":"consumers","name":"dubbo.io","organization":"dubbo-go","owner":"dubbo-go","path":"/com.sample.base.client.rpc.GrayFacade","protocol":"nacos","provided-by":"","reference.filter":"generic,cshutdown","registry.role":"0","release":"dubbo-golang-3.0.0","retries":"","serialization":"","side":"consumer","sticky":"false","timestamp":"1658470313","version":"1.0"},"scheduled":false}> 2022-07-22T14:31:05.401+0800 WARN proxy/proxy.go:210 [CallProxy] received rpc err: Failed to invoke the method $invoke. No provider available for the service nacos://:@10.10.10.99:80/?interface=com.sample.base.client.rpc.GrayFacade&group=&version=1.0 from registry nacos://10.10.10.66:8848?nacos.access=&nacos.group=DEFAULT_GROUP&nacos.namespaceId=6666667e-c02b-4768-95d8-804de56exxxx&nacos.password=&nacos.secret=&nacos.timeout=60&nacos.username=&registry=nacos&registry.group=&registry.label=true&registry.namespace=6666667e-c02b-4768-95d8-804de56exxxx&registry.preferred=false&registry.role=0&registry.timeout=60&registry.ttl=60&registry.weight=0&registry.zone=&remote-client-name=dubbo.registries-nacos-10.10.10.66%3A8848&simplified=false on the consumer 10.10.10.99 using the dubbo version 3.0.0 .Please check if the providers have been started and registered. 2022-07-22T14:31:05.401+0800 INFO nacos/registry.go:204 [Nacos Registry] Update begin, service event: ServiceEvent{Action{add}, Path{dubbo://10.10.10.88:28082/com.sample.base.client.rpc.GrayFacade?application=monkey-etna&category=providers&deprecated=false&dubbo=2.0.2&path=com.sample.base.client.rpc.GrayFacade&protocol=dubbo&release=2.7.8&serialization=hessian2&timeout=30000&timestamp=1656558763173&version=1.0}, Key{}} 2022/07/22 14:31:09 ================================= 2022/07/22 14:31:10 Failed to invoke the method $invoke. No provider available for the service nacos://:@10.10.10.99:80/?interface=com.sample.base.client.rpc.GrayFacade&group=&version=1.0 from registry nacos://10.10.10.66:8848?nacos.access=&nacos.group=DEFAULT_GROUP&nacos.namespaceId=6666667e-c02b-4768-95d8-804de56exxxx&nacos.password=&nacos.secret=&nacos.timeout=60&nacos.username=&registry=nacos&registry.group=&registry.label=true&registry.namespace=6666667e-c02b-4768-95d8-804de56exxxx&registry.preferred=false&registry.role=0&registry.timeout=60&registry.ttl=60&registry.weight=0&registry.zone=&remote-client-name=dubbo.registries-nacos-10.10.10.66%3A8848&simplified=false on the consumer 10.10.10.99 using the dubbo version 3.0.0 .Please check if the providers have been started and registered.

dubbo-go版本:3.0.2 版本: release=2.7.8 deprecated=false dubbo=2.0.2

根据例子编写,请问是啥原因导致的?

zyklonwu avatar Jul 22 '22 06:07 zyklonwu

which sample?

AlexStocks avatar Jul 22 '22 10:07 AlexStocks

which sample?

package main

import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/cluster/router" _ "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/generic" _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" hessian "github.com/apache/dubbo-go-hessian2" "github.com/dubbogo/net/context" _ "github.com/nacos-group/nacos-sdk-go/clients" _ "github.com/nacos-group/nacos-sdk-go/common/constant" "log" )

const appName = "dubbo.io"

func newRefConf(interfaceName string, protocol string, address string, namespace string) config.ReferenceConfig { registryConfig := &config.RegistryConfig{ Protocol: protocol, Address: address, Namespace: namespace, Timeout: "60", TTL: "60", }

refConf := config.ReferenceConfig{
	InterfaceName: interfaceName,
	Cluster:       "failover",
	RegistryIDs:   []string{"test-wb"},
	Protocol:      protocol,
	Generic:       "true",
	Async: true,
	Version:  "1.0",
}

rootConfig := config.NewRootConfigBuilder().
	AddRegistry("test-wb", registryConfig).
	Build()
if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
	panic(err)
}
errr := refConf.Init(rootConfig)
if errr != nil {
	panic(errr)
}
refConf.GenericLoad(appName)

return refConf

}

func main() {

refConf := newRefConf("com.xxx.base.client.rpc.GrayFacade", "nacos",
	"10.18.66.1:8848", "8888637e-c02b-4768-95d8-804de56exxxx")

resp, err := refConf.
	GetRPCService().(*generic.GenericService).
	Invoke(
		context.TODO(),
		"inGray",
		[]string{"com.xxx.base.client.dto.req.InGrayReqDTO"},
		[]hessian.Object{map[string]string{"bizType":"ORDER_STAGE_1","shardingId":"20035","flowNo":"2022071516251030135"}},
	)
log.Println("=================================")
log.Println(err)
log.Println("++++++++++++++++++++++++++++++++++")
log.Println(resp)

}

zyklonwu avatar Jul 22 '22 10:07 zyklonwu

dubbo-go版本:3.0.2 版本: release=2.7.8 deprecated=false dubbo=2.0.2

Hi @zyklonwu, as you mentioned in this issue, are you using dubbo-java 2.7.8 and dubbo-go 3.0.2?

UPDATE 1: Please format your code to make it clearer. It is better if you can upload your source code. If you are concerned about making your source code public, you can send it privately via DingTalk.

UPDATE 2: If you don't want to share your code, please let us know about what config you are using in java, and how to implement your dubbo-java server you are using.

justxuewei avatar Jul 22 '22 14:07 justxuewei

dubbo-go版本:3.0.2 版本: release=2.7.8 deprecated=false dubbo=2.0.2

Hi @zyklonwu, as you mentioned in this issue, are you using dubbo-java 2.7.8 and dubbo-go 3.0.2?

UPDATE 1: Please format your code to make it clearer. It is better if you can upload your source code. If you are concerned about making your source code public, you can send it privately via DingTalk.

@zyklonwu u can also join dingding group 31363295 and contact with me, yuyu, the group owner.

AlexStocks avatar Jul 22 '22 14:07 AlexStocks

Hi, @zyklonwu, I can reproduce the problem you mentioned above, and I uploaded the test code on GitHub. This problem is probably caused by Nacos registry on the Dubbo-go, not the generic service. I asked @zhaoyunxing92 to look at this, cc @sanxun0325.

justxuewei avatar Jul 25 '22 11:07 justxuewei

Hi, @zyklonwu, I can reproduce the problem you mentioned above, and I uploaded the test code on GitHub. This problem is probably caused by Nacos registry on the Dubbo-go, not the generic service. I asked @zhaoyunxing92 to look at this, cc @sanxun0325.

谢谢,我在钉钉群里面反馈了

zyklonwu avatar Jul 26 '22 06:07 zyklonwu

注册完成后添加几秒睡眠 image

zhaoyunxing92 avatar Aug 08 '22 01:08 zhaoyunxing92

注册完成后添加几秒睡眠 image

是不是可以通过同步机制解决,而不是这种 sleep 的手段,就算是 sleep,sleep 多久算合适呢?

AlexStocks avatar Aug 08 '22 03:08 AlexStocks

注册完成后添加几秒睡眠 image

是不是可以通过同步机制解决,而不是这种 sleep 的手段,就算是 sleep,sleep 多久算合适呢?

一般2秒就可以了

zhaoyunxing92 avatar Aug 08 '22 03:08 zhaoyunxing92

注册完成后添加几秒睡眠 image

是不是可以通过同步机制解决,而不是这种 sleep 的手段,就算是 sleep,sleep 多久算合适呢?

一般2秒就可以了

我的意思是,可以再加个接口,这个接口返回一个 chan,当内部任务完成的时候通过chan返回给应用端一个信号。

而不是这种 sleep 一段时间的方式。

AlexStocks avatar Aug 08 '22 03:08 AlexStocks

注册完成后添加几秒睡眠 image

没用,还是不行

zyklonwu avatar Aug 08 '22 03:08 zyklonwu

你可以按照我的例子跑一下试试,挂在你们的注册中心里。发自我的 iPhone在 2022年8月8日,11:52,zyklonwu @.***> 写道:

注册完成后添加几秒睡眠

没用,还是不行

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were assigned.Message ID: @.***>

justxuewei avatar Aug 08 '22 04:08 justxuewei

你可以按照我的例子跑一下试试,挂在你们的注册中心里。发自我的 iPhone在 2022年8月8日,11:52,zyklonwu @.> 写道: 注册完成后添加几秒睡眠 没用,还是不行 —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were assigned.Message ID: @.> 报错了 panic: loadbalance for random is not existing, make sure you have import the package.

goroutine 1 [running]: dubbo.apache.org/dubbo-go/v3/common/extension.GetLoadbalance(...) /Users/wubo/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/common/extension/loadbalance.go:35 dubbo.apache.org/dubbo-go/v3/cluster/cluster/base.GetLoadBalance({0x4ada8c0, 0xc000492f00}, {0x49a3423, 0x6}) /Users/wubo/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/cluster/cluster/base/cluster_invoker.go:183 +0x194 dubbo.apache.org/dubbo-go/v3/cluster/cluster/failover.(*failoverClusterInvoker).Invoke(0xc000492ab0, {0x4ada428, 0xc000132010}, {0x4af1510, 0xc00053c4e0}) /Users/wubo/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/cluster/cluster/failover/cluster_invoker.go:64 +0x132 dubbo.apache.org/dubbo-go/v3/common/proxy.DefaultProxyImplementFunc.func1.1({0xc00051d4a0, 0x4, 0x8}) /Users/wubo/go/pkg/mod/dubbo.apache.org/dubbo-go/[email protected]/common/proxy/proxy.go:200 +0x9a4 main.main() /Users/wubo/go/workspace/awesomeProject/main.go:89 +0x29d

Process finished with the exit code 2

zyklonwu avatar Aug 08 '22 06:08 zyklonwu

panic: loadbalance for random is not existing, make sure you have import the package.

如果需要使用 random lb,需要你在 client 端加入一个新的 import: import _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random".

justxuewei avatar Aug 08 '22 06:08 justxuewei

panic: loadbalance for random is not existing, make sure you have import the package.

如果需要使用 random lb,需要你在 client 端加入一个新的 import: import _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random".

解决了,多谢

zyklonwu avatar Aug 08 '22 06:08 zyklonwu

学蔚:不 sleep 就无法解决问题

AlexStocks avatar Sep 23 '22 14:09 AlexStocks

请问泛化调用后的结果 resp 如何转为 map 或者 struct 呢?

lijialiang avatar Dec 23 '22 05:12 lijialiang