//这里面的配置接受内容的长度过长,是因为当时做了写音视频编码为base64的转发
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS));
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(1024 * 1024));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new WebSocketServerProtocolHandler("/ws", null, true, 1024 * 512));
pipeline.addLast(new TextWebSocketFrameHandler());
// 配置ssl访问的
SSLContext sslContext = SslUtil.createSSLContext("PKCS12",
this.getClass().getClassLoader().getResourceAsStream("keystore.p12"), "changeit"); //
SSLEngine engine =sslContext.createSSLEngine();
SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setNeedClientAuth(false);
sslEngine.setUseClientMode(false);
pipeline.addFirst(new SslHandler(sslEngine));
}
复制代码