Fix unable to receive go away frame (#13228)
* Fix unable to receive go away frame * Rename * rename
This commit is contained in:
parent
3f07e683a1
commit
02e486a1dc
|
|
@ -178,4 +178,7 @@ public interface Constants {
|
|||
String CONTENT_LENGTH_KEY = "content-length";
|
||||
|
||||
String USE_SECURE_RANDOM_ID = "dubbo.application.use-secure-random-request-id";
|
||||
|
||||
String CONNECTION_HANDLER_NAME = "connectionHandler";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.apache.dubbo.common.logger.LoggerFactory;
|
|||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
import org.apache.dubbo.remoting.Constants;
|
||||
import org.apache.dubbo.remoting.RemotingException;
|
||||
import org.apache.dubbo.remoting.api.WireProtocol;
|
||||
import org.apache.dubbo.remoting.api.connection.AbstractConnectionClient;
|
||||
|
|
@ -123,7 +124,7 @@ public class NettyConnectionClient extends AbstractConnectionClient {
|
|||
int heartbeat = UrlUtils.getHeartbeat(getUrl());
|
||||
pipeline.addLast("client-idle-handler", new IdleStateHandler(heartbeat, 0, 0, MILLISECONDS));
|
||||
|
||||
pipeline.addLast("connectionHandler", connectionHandler);
|
||||
pipeline.addLast(Constants.CONNECTION_HANDLER_NAME, connectionHandler);
|
||||
|
||||
NettyConfigOperator operator = new NettyConfigOperator(nettyChannel, getChannelHandler());
|
||||
protocol.configClientPipeline(getUrl(), operator, nettySslContextOperator);
|
||||
|
|
|
|||
|
|
@ -17,15 +17,6 @@
|
|||
|
||||
package org.apache.dubbo.rpc.protocol.tri;
|
||||
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.http2.Http2FrameCodec;
|
||||
import io.netty.handler.codec.http2.Http2FrameLogger;
|
||||
import io.netty.handler.codec.http2.Http2MultiplexHandler;
|
||||
import io.netty.handler.codec.http2.Http2Settings;
|
||||
import io.netty.handler.codec.http2.Http2StreamChannel;
|
||||
import io.netty.handler.flush.FlushConsolidationHandler;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.Configuration;
|
||||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
|
|
@ -42,13 +33,24 @@ import org.apache.dubbo.rpc.HeaderFilter;
|
|||
import org.apache.dubbo.rpc.executor.ExecutorSupport;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
import org.apache.dubbo.rpc.model.ScopeModelAware;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleClientHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleCommandOutBoundHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleGoAwayHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleHttp2FrameServerHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleServerConnectionHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleTailHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.transport.TripleWriteQueue;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.http2.Http2FrameCodec;
|
||||
import io.netty.handler.codec.http2.Http2FrameLogger;
|
||||
import io.netty.handler.codec.http2.Http2MultiplexHandler;
|
||||
import io.netty.handler.codec.http2.Http2Settings;
|
||||
import io.netty.handler.codec.http2.Http2StreamChannel;
|
||||
import io.netty.handler.flush.FlushConsolidationHandler;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -161,11 +163,10 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo
|
|||
.frameLogger(CLIENT_LOGGER)
|
||||
.build();
|
||||
codec.connection().local().flowController().frameWriter(codec.encoder().frameWriter());
|
||||
final Http2MultiplexHandler handler = new Http2MultiplexHandler(
|
||||
new TripleClientHandler(frameworkModel));
|
||||
List<ChannelHandler> handlers = new ArrayList<>();
|
||||
handlers.add(new ChannelHandlerPretender(codec));
|
||||
handlers.add(new ChannelHandlerPretender(handler));
|
||||
handlers.add(new ChannelHandlerPretender(new Http2MultiplexHandler(new ChannelDuplexHandler())));
|
||||
handlers.add(new ChannelHandlerPretender(new TripleGoAwayHandler()));
|
||||
handlers.add(new ChannelHandlerPretender(new TriplePingPongHandler(UrlUtils.getCloseTimeout(url))));
|
||||
handlers.add(new ChannelHandlerPretender(new TripleTailHandler()));
|
||||
operator.configChannelHandler(handlers);
|
||||
|
|
|
|||
|
|
@ -17,28 +17,24 @@
|
|||
|
||||
package org.apache.dubbo.rpc.protocol.tri.transport;
|
||||
|
||||
import org.apache.dubbo.remoting.Constants;
|
||||
import org.apache.dubbo.remoting.api.connection.ConnectionHandler;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http2.Http2GoAwayFrame;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
|
||||
public class TripleClientHandler extends ChannelDuplexHandler {
|
||||
public class TripleGoAwayHandler extends ChannelDuplexHandler {
|
||||
|
||||
private final FrameworkModel frameworkModel;
|
||||
|
||||
private static final String CONNECTION_HANDLER_NAME = "connectionHandler";
|
||||
|
||||
public TripleClientHandler(FrameworkModel frameworkModel) {
|
||||
this.frameworkModel = frameworkModel;
|
||||
public TripleGoAwayHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof Http2GoAwayFrame) {
|
||||
final ConnectionHandler connectionHandler = (ConnectionHandler) ctx.pipeline().get(CONNECTION_HANDLER_NAME);
|
||||
final ConnectionHandler connectionHandler = (ConnectionHandler) ctx.pipeline().get(Constants.CONNECTION_HANDLER_NAME);
|
||||
connectionHandler.onGoAway(ctx.channel());
|
||||
}
|
||||
ReferenceCountUtil.release(msg);
|
||||
Loading…
Reference in New Issue