mirror of
https://gitee.com/arthas/arthas.git
synced 2024-12-02 04:08:34 +08:00
fix tunnel proxy websocket can not process frame length larger than 65536 problem. #2152
This commit is contained in:
parent
fc37ff7d38
commit
39760baf17
@ -14,7 +14,7 @@ public class ArthasConstants {
|
||||
*/
|
||||
public static final String NETTY_LOCAL_ADDRESS = "arthas-netty-LocalAddress";
|
||||
|
||||
public static final int MAX_HTTP_CONTENT_LENGTH = 1024 * 1024 * 8;
|
||||
public static final int MAX_HTTP_CONTENT_LENGTH = 1024 * 1024 * 10;
|
||||
|
||||
public static final String ARTHAS_OUTPUT = "arthas-output";
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class LocalTtyServerInitializer extends ChannelInitializer<LocalChannel>
|
||||
pipeline.addLast(new ChunkedWriteHandler());
|
||||
pipeline.addLast(new HttpObjectAggregator(ArthasConstants.MAX_HTTP_CONTENT_LENGTH));
|
||||
pipeline.addLast(workerGroup, "HttpRequestHandler", new HttpRequestHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, true));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, null, false, ArthasConstants.MAX_HTTP_CONTENT_LENGTH, false, true));
|
||||
pipeline.addLast(new IdleStateHandler(0, 0, ArthasConstants.WEBSOCKET_IDLE_SECONDS));
|
||||
pipeline.addLast(new TtyWebSocketFrameHandler(group, handler));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class TtyServerInitializer extends ChannelInitializer<SocketChannel> {
|
||||
pipeline.addLast(new HttpObjectAggregator(ArthasConstants.MAX_HTTP_CONTENT_LENGTH));
|
||||
pipeline.addLast(new BasicHttpAuthenticatorHandler(httpSessionManager));
|
||||
pipeline.addLast(workerGroup, "HttpRequestHandler", new HttpRequestHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, true));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, null, false, ArthasConstants.MAX_HTTP_CONTENT_LENGTH, false, true));
|
||||
pipeline.addLast(new IdleStateHandler(0, 0, ArthasConstants.WEBSOCKET_IDLE_SECONDS));
|
||||
pipeline.addLast(new TtyWebSocketFrameHandler(group, handler));
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class ProtocolDetectHandler extends ChannelInboundHandlerAdapter {
|
||||
pipeline.addLast(new HttpObjectAggregator(ArthasConstants.MAX_HTTP_CONTENT_LENGTH));
|
||||
pipeline.addLast(new BasicHttpAuthenticatorHandler(httpSessionManager));
|
||||
pipeline.addLast(workerGroup, "HttpRequestHandler", new HttpRequestHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, true));
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(ArthasConstants.DEFAULT_WEBSOCKET_PATH, null, false, ArthasConstants.MAX_HTTP_CONTENT_LENGTH, false, true));
|
||||
pipeline.addLast(new IdleStateHandler(0, 0, ArthasConstants.WEBSOCKET_IDLE_SECONDS));
|
||||
pipeline.addLast(new TtyWebSocketFrameHandler(channelGroup, ttyConnectionFactory));
|
||||
ctx.fireChannelActive();
|
||||
|
@ -4,6 +4,7 @@ import com.alibaba.arthas.deps.org.slf4j.Logger;
|
||||
import com.alibaba.arthas.deps.org.slf4j.LoggerFactory;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.taobao.arthas.common.ArthasConstants;
|
||||
import com.taobao.arthas.core.GlobalOptions;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@ -22,7 +23,7 @@ import static java.lang.String.format;
|
||||
public class ObjectView implements View {
|
||||
public static final int MAX_DEEP = 4;
|
||||
private static final Logger logger = LoggerFactory.getLogger(ObjectView.class);
|
||||
private final static int MAX_OBJECT_LENGTH = 10 * 1024 * 1024; // 10M
|
||||
private final static int MAX_OBJECT_LENGTH = ArthasConstants.MAX_HTTP_CONTENT_LENGTH;
|
||||
|
||||
private final Object object;
|
||||
private final int deep;
|
||||
|
@ -20,13 +20,10 @@ import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpClientCodec;
|
||||
import io.netty.handler.codec.http.HttpObjectAggregator;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolConfig;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
@ -75,9 +72,12 @@ public class ForwardClient {
|
||||
}
|
||||
|
||||
// connect to local server
|
||||
WebSocketClientHandshaker newHandshaker = WebSocketClientHandshakerFactory.newHandshaker(tunnelServerURI,
|
||||
WebSocketVersion.V13, null, true, new DefaultHttpHeaders());
|
||||
final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(newHandshaker);
|
||||
WebSocketClientProtocolConfig clientProtocolConfig = WebSocketClientProtocolConfig.newBuilder()
|
||||
.webSocketUri(tunnelServerURI)
|
||||
.maxFramePayloadLength(ArthasConstants.MAX_HTTP_CONTENT_LENGTH).build();
|
||||
|
||||
final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(
|
||||
clientProtocolConfig);
|
||||
|
||||
final ForwardClientSocketClientHandler forwardClientSocketClientHandler = new ForwardClientSocketClientHandler();
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.alibaba.arthas.tunnel.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -22,15 +21,12 @@ import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
import io.netty.channel.local.LocalChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpClientCodec;
|
||||
import io.netty.handler.codec.http.HttpObjectAggregator;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolConfig;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler.ClientHandshakeStateEvent;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
@ -71,10 +67,13 @@ public class ForwardClientSocketClientHandler extends SimpleChannelInboundHandle
|
||||
try {
|
||||
logger.info("ForwardClientSocketClientHandler star connect local arthas server");
|
||||
// 入参URI实际无意义,只为了程序不出错
|
||||
WebSocketClientHandshaker newHandshaker = WebSocketClientHandshakerFactory.newHandshaker(new URI("ws://127.0.0.1:8563/ws"),
|
||||
WebSocketVersion.V13, null, true, new DefaultHttpHeaders());
|
||||
WebSocketClientProtocolConfig clientProtocolConfig = WebSocketClientProtocolConfig.newBuilder()
|
||||
.webSocketUri("ws://127.0.0.1:8563/ws")
|
||||
.maxFramePayloadLength(ArthasConstants.MAX_HTTP_CONTENT_LENGTH).build();
|
||||
|
||||
final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(
|
||||
newHandshaker);
|
||||
clientProtocolConfig);
|
||||
|
||||
final LocalFrameHandler localFrameHandler = new LocalFrameHandler();
|
||||
|
||||
Bootstrap b = new Bootstrap();
|
||||
|
@ -23,14 +23,11 @@ import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpClientCodec;
|
||||
import io.netty.handler.codec.http.HttpObjectAggregator;
|
||||
import io.netty.handler.codec.http.QueryStringEncoder;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolConfig;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
@ -110,9 +107,12 @@ public class TunnelClient {
|
||||
sslCtx = null;
|
||||
}
|
||||
|
||||
WebSocketClientHandshaker newHandshaker = WebSocketClientHandshakerFactory.newHandshaker(agentRegisterURI,
|
||||
WebSocketVersion.V13, null, true, new DefaultHttpHeaders());
|
||||
final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(newHandshaker);
|
||||
WebSocketClientProtocolConfig clientProtocolConfig = WebSocketClientProtocolConfig.newBuilder()
|
||||
.webSocketUri(agentRegisterURI)
|
||||
.maxFramePayloadLength(ArthasConstants.MAX_HTTP_CONTENT_LENGTH).build();
|
||||
|
||||
final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(
|
||||
clientProtocolConfig);
|
||||
final TunnelClientSocketClientHandler handler = new TunnelClientSocketClientHandler(TunnelClient.this);
|
||||
|
||||
Bootstrap bs = new Bootstrap();
|
||||
|
Loading…
Reference in New Issue
Block a user