[alibaba/arthas]添加 http api 的 tunnel 端的 proxy

2024-07-09 179 views
5

我想在 tunnel server 端加上 http api 的代理;如代码所示,tunnel server 请求 /apiProxy/{agentId}/api,最终会被 tunnel client 转为 localhost/api

回答

5

我在LocalTtyServerInitializer和ProxyClient分别加了测试用的channelHandler,发现从Server返回的数据是正常的,但是从proxyClient接收的数据只有http的头部和一个空格,http消息的body没有收到,应该是这个原因导致超时卡住。那感觉可能和 localChannel 有关了

============================================================================================

update at 2021-12-20 21:03 proxyClient接收到2块数据。第一块是 http 的头信息,是一个正常的 PooledUnsafeHeapByteBuf;而第二块是UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf。第二块内容的 array 里是正常的 bytes,内容也是 http 的body信息,但是UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf的writerIndex是0

============================================================================================ update at 2022-01-04 12:06 http 的 response 会分成 2块(http header 和 http body)进入 readInbound,但是在第二次 localChannel.readInbound(即 http body)之前,触发了一次 localChannel.releaseInboundBuffers,而 releaseInboundBuffers 是来自 close 事件。目前还不清楚这个 close 事件是哪来的