【发布时间】:2019-08-19 04:15:32
【问题描述】:
我想用netty完成一个功能
http 发送数据到 netty -> netty 代理数据到目标 https
我启动一个客户端来连接目标链接。
我试过代理到http,没关系
但是当我使用 https 链接时,future.isSuccess() 返回 false
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof FullHttpRequest) {
FullHttpRequest request = (FullHttpRequest) msg;
Bootstrap b = new Bootstrap();
b.group(ctx.channel().eventLoop())
.channel(ctx.channel().getClass())
.handler(new HttpProxyInitializer(ctx.channel()));
ChannelFuture f = b.connect("https://xxxx",443);
outboundChannel = f.channel();
f.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
if (future.isSuccess()) {
future.channel().writeAndFlush(msg);
} else {
ctx.channel().close();
}
}
});
}
}
那么netty connet https不可行吗?
【问题讨论】: