xxxcrel opened a new issue #9824: URL: https://github.com/apache/dubbo/issues/9824
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy --> - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate. ### Environment * Dubbo version: 2.7.15 * Operating System version: Ubuntu 20.04 * Java version: 1.8.0_311 ### Steps to reproduce this issue 1. `create a local stub` ```Java package org.apache.dubbo.demo.consumer; import org.apache.dubbo.demo.DemoService; public class DemoServiceLocal implements DemoService { private DemoService demoService; public DemoServiceLocal(DemoService demoService) { this.demoService = demoService; } @Override public String sayHello(String name) { return demoService.sayHello(name); } public void onConnect() { System.out.println("DemoServiceLocal.onConnect()"); } public void onDisconnect() { System.out.println("DemoServiceLocal.onDisconnect()"); } } ``` 2. `configure ReferenceConfig use the stub and enable stubevent(onconnect, ondisconnect)` ```Java package org.apache.dubbo.demo.consumer; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.bootstrap.DubboBootstrap; import org.apache.dubbo.demo.DemoService; public class Application { public static void main(String[] args) { runWithBootstrap(); } private static void runWithBootstrap() { ReferenceConfig<DemoService> reference = new ReferenceConfig<>(); reference.setInterface(DemoService.class); reference.setCheck(false); reference.setStub("org.apache.dubbo.demo.consumer.DemoServiceLocal"); reference.setOnconnect("onConnect"); reference.setOndisconnect("onDisconnect"); DubboBootstrap bootstrap = DubboBootstrap.getInstance(); bootstrap.application(new ApplicationConfig("dubbo-demo-api-consumer")) .registry(new RegistryConfig("nacos://127.0.0.1:8848")) .reference(reference) .start() .await();//we don't use demoService is only for test stubevent } } ``` 3. launch Consumer Application, `It will start successfully and to nacos subscribe to the DemoService` 4. launch Provider Application ```Java package org.apache.dubbo.demo.provider; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.ServiceConfig; import org.apache.dubbo.config.bootstrap.DubboBootstrap; import org.apache.dubbo.demo.DemoService; public class Application { public static void main(String[] args) throws Exception { startWithBootstrap(); } private static void startWithBootstrap() { ServiceConfig<DemoServiceImpl> service = new ServiceConfig<>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); DubboBootstrap bootstrap = DubboBootstrap.getInstance(); bootstrap.application(new ApplicationConfig("dubbo-demo-api-provider")) .registry(new RegistryConfig("nacos://127.0.0.1:8848")) .service(service) .start() .await(); } } ``` 5. consumer side will print onconnect event, but throw an exception ```Java 22/03/22 21:45:23:320 CST] DubboClientHandler-thread-1 WARN dubbo.DubboProtocol: [DUBBO] Failed to invoke event method onConnect(), cause: Not found exported service: org.apache.dubbo.demo.DemoService:20880 in [org.apache.dubbo.demo.DemoService:0], may be version or group mismatch , channel: consumer: /172.20.0.1:20880 --> provider: /172.20.0.1:47754, message:RpcInvocation [methodName=onConnect, parameterTypes=[], arguments=[], attachments={path=org.apache.dubbo.demo.DemoService, dubbo.stub.event=true, interface=org.apache.dubbo.demo.DemoService, version=null, group=null}], dubbo version: , current host: 172.20.0.1 org.apache.dubbo.remoting.RemotingException: Not found exported service: org.apache.dubbo.demo.DemoService:20880 in [org.apache.dubbo.demo.DemoService:0], may be version or group mismatch , channel: consumer: /172.20.0.1:20880 --> provider: /172.20.0.1:47754, message:RpcInvocation [methodName=onConnect, parameterTypes=[], arguments=[], attachments={path=org.apache.dubbo.demo.DemoService, dubbo.stub.event=true, interface=org.apache.dubbo.demo.DemoService, version=null, group=null}] at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.getInvoker(DubboProtocol.java:267) at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:123) at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.received(DubboProtocol.java:155) at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.invoke(DubboProtocol.java:179) at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.connected(DubboProtocol.java:164) at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.connected(HeaderExchangeHandler.java:125) at org.apache.dubbo.remoting.transport.AbstractChannelHandlerDelegate.connected(AbstractChannelHandlerDelegate.java:43) at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:66) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) at java.lang.Thread.run(Thread.java:748) [22/03/22 21:45:23:321 CST] nacos.publisher-com.alibaba.nacos.client.naming.event.InstancesChangeEvent INFO transport.AbstractClient: [DUBBO] Successed connect to server /172.20.0.1:20880 from NettyClient 172.20.0.1 using dubbo version , channel is NettyChannel [channel=[id: 0x4189abc3, L:/172.20.0.1:47754 - R:/172.20.0.1:20880]], dubbo version: , current host: 172.20.0.1 [22/03/22 21:45:23:322 CST] nacos.publisher-com.alibaba.nacos.client.naming.event.InstancesChangeEvent INFO transport.AbstractClient: [DUBBO] Start NettyClient /172.20.0.1 connect to the server /172.20.0.1:20880, dubbo version: , current host: 172.20.0.1 ``` Pls. provide [GitHub address] to reproduce this issue. ### Expected Behavior <!-- What do you expect from the above steps?--> ### Actual Behavior <!-- What actually happens? --> If there is an exception, please attach the exception trace: ``` Just put your stack trace here! ``` -- 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]
