reset all active stream on connection close (#12451)

* reset all active stream on connection close

* reset all active stream on connection close
This commit is contained in:
icodening 2023-06-07 11:03:26 +08:00 committed by GitHub
parent 00d8a46cd5
commit eba976fec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -52,7 +52,7 @@ public class BiStreamServerCallListener extends AbstractServerCallListener {
@Override
public void onCancel(TriRpcStatus status) {
responseObserver.onError(status.asException());
requestObserver.onError(status.asException());
}

View File

@ -17,6 +17,8 @@
package org.apache.dubbo.rpc.protocol.tri.transport;
import io.netty.handler.codec.http2.DefaultHttp2ResetFrame;
import io.netty.handler.codec.http2.Http2Error;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -67,6 +69,17 @@ public class TripleServerConnectionHandler extends Http2ChannelDuplexHandler {
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
//reset all active stream on connection close
forEachActiveStream(stream -> {
DefaultHttp2ResetFrame resetFrame = new DefaultHttp2ResetFrame(Http2Error.NO_ERROR).stream(stream);
ctx.fireChannelRead(resetFrame);
return true;
});
}
private boolean isQuiteException(Throwable t) {
if (QUIET_EXCEPTIONS_CLASS.contains(t.getClass())) {
return true;