apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.55k stars 26.44k forks source link

dubbo:3.2 Triple Server NPE when client connect and disconnect #12855

Closed chaoyoung closed 8 months ago

chaoyoung commented 1 year ago

Environment

Steps

Triple client 在连接和断开Triple server时,server端分别出现NPE。

Expected Behavior

No NPE

Actual Behavior

NPE

exception trace:

2023-08-14 17:21:34.605  INFO 1 --- [rverWorker-14-7] d.r.transport.netty4.NettyChannelHandler:55 :  [DUBBO] The connection of /10.244.232.0:58536 -> /10.244.24.215:50051 is established., dubbo version: 3.2.5, current host: 10.244.24.215
2023-08-14 17:21:36.107 ERROR 1 --- [0051-thread-199] o.a.d.c.t.serial.SerializingExecutor    :? :  [DUBBO] Exception while executing runnable org.apache.dubbo.rpc.protocol.tri.stream.TripleServerStream$ServerTransportObserver$$Lambda$2696/704937895@63104b52, dubbo version: 3.2.5, current host: 10.244.24.215, error code: 0-19. This may be caused by , go to https://dubbo.apache.org/faq/0/19 to find instructions.

java.lang.NullPointerException: null
    at org.apache.dubbo.rpc.protocol.tri.ReflectionPackableMethod.<init>(ReflectionPackableMethod.java:78) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.ReflectionPackableMethod.init(ReflectionPackableMethod.java:127) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.DefaultPackableMethodFactory.create(DefaultPackableMethodFactory.java:29) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.call.ReflectionAbstractServerCall.startCall(ReflectionAbstractServerCall.java:126) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.call.AbstractServerCall.onHeader(AbstractServerCall.java:134) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleServerStream$ServerTransportObserver.processHeader(TripleServerStream.java:428) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleServerStream$ServerTransportObserver.lambda$onHeader$0(TripleServerStream.java:331) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:102) ~[dubbo-3.2.5.jar:3.2.5]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
    at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) [dubbo-3.2.5.jar:3.2.5]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

2023-08-14 17:21:41.102  INFO 1 --- [rverWorker-14-7] .d.r.transport.netty4.NettyServerHandler:90 :  [DUBBO] The connection of /10.244.232.0:58536 -> /10.244.24.215:50051 is disconnected., dubbo version: 3.2.5, current host: 10.244.24.215
2023-08-14 17:21:41.103  WARN 1 --- [rverWorker-14-7] .d.r.p.t.t.TripleHttp2FrameServerHandler:? :  [DUBBO] Triple Server received remote reset errorCode=0, dubbo version: 3.2.5, current host: 10.244.24.215, error code: 4-14. This may be caused by , go to https://dubbo.apache.org/faq/4/14 to find instructions.
2023-08-14 17:21:41.104  WARN 1 --- [rverWorker-14-7] .dubbo.remoting.transport.AbstractServer:? :  [DUBBO] All clients has disconnected from /10.244.24.215:50051. You can graceful shutdown now., dubbo version: 3.2.5, current host: 10.244.24.215, error code: 99-0. This may be caused by unknown error in remoting module, go to https://dubbo.apache.org/faq/99/0 to find instructions.
2023-08-14 17:21:41.104 ERROR 1 --- [0051-thread-199] o.a.d.c.t.serial.SerializingExecutor    :? :  [DUBBO] Exception while executing runnable org.apache.dubbo.rpc.protocol.tri.stream.TripleServerStream$ServerTransportObserver$$Lambda$2702/1532370849@57d9e340, dubbo version: 3.2.5, current host: 10.244.24.215, error code: 0-19. This may be caused by , go to https://dubbo.apache.org/faq/0/19 to find instructions.

java.lang.NullPointerException: null
    at org.apache.dubbo.rpc.protocol.tri.call.AbstractServerCall.onCancelByRemote(AbstractServerCall.java:232) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.rpc.protocol.tri.stream.TripleServerStream$ServerTransportObserver.lambda$cancelByRemote$3(TripleServerStream.java:458) ~[dubbo-3.2.5.jar:3.2.5]
    at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:102) ~[dubbo-3.2.5.jar:3.2.5]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
    at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) [dubbo-3.2.5.jar:3.2.5]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

2023-08-14 17:21:41.105  INFO 1 --- [rverWorker-14-7] d.r.transport.netty4.NettyChannelHandler:69 :  [DUBBO] The connection of /10.244.232.0:58536 -> /10.244.24.215:50051 is disconnected., dubbo version: 3.2.5, current host: 10.244.24.215
EarthChen commented 1 year ago

麻烦贴一下你的 interface 定义

chaoyoung commented 1 year ago

@EarthChen interface定义由proto文件编译生成:

image

Debug:

image image

这里的MethodDescriptor实现类是StubMethodDescriptor,这个类中的getMethod()方法返回null,导致了NPE问题。请问如何修复。

EarthChen commented 1 year ago

升级一下 compiler 版本,保持和dubbo 版本一致即可

chaoyoung commented 1 year ago

@EarthChen compiler版本和dubbo版本是一致的。

            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
                    <protocPlugins>
                        <protocPlugin>
                            <id>dubbo</id>
                            <groupId>org.apache.dubbo</groupId>
                            <artifactId>dubbo-compiler</artifactId>
                            <version>${dubbo.version}</version>
                            <mainClass>org.apache.dubbo.gen.tri.Dubbo3TripleGenerator</mainClass>
                        </protocPlugin>
                    </protocPlugins>
                </configuration>
            <!-- ...-->
            </plugin>
syntax = "proto3";

option java_multiple_files = true;
option java_package = "org.example.dubbo.rpc";
option java_outer_classname = "VoiceChatProto";

package org.example.dubbo.chat;

service VoiceChat {

  rpc chat(stream VoiceChatRequest) returns (stream VoiceChatResponse);

}

message VoiceChatRequest {
  string callId = 1;
  bytes data = 3;
}

message VoiceChatResponse {
  string callId = 1;
  bytes data = 2;
}

ps: 这里java_package和package的值不一样 option java_package = "org.example.dubbo.rpc"; package org.example.dubbo.chat;

客户端使用java_package的path导致了server端NPE

        ReferenceConfig<VoiceChat> ref = new ReferenceConfig<>();
        ref.setInterface(VoiceChat.class);
        ref.setProtocol("tri");
        ref.setVersion("1.0");
        ref.setUrl("tri://localhost:50051/org.example.dubbo.rpc.VoiceChat");

复现步骤:

EarthChen commented 1 year ago

因为你定义了 package 所以path 应该是org.example.dubbo.chat,java_package 只是个java 侧的包路径,不作为请求path

EarthChen commented 1 year ago

npe 问题我们会优化一下提示

AlbumenJ commented 8 months ago

No news is good news. Please feel free to create a new issue if you have any question.