java internal修饰 Exception: io.netty.handler.codec.DecoderException: java.io.IOExcep 还有什么 id:64

类 MessageToMessageDecoder&I,O&
java.lang.Object
io.netty.handler.codec.MessageToMessageDecoder&I,O&
所有已实现的接口:
直接已知子类:
, , , , , , ,
public abstract class MessageToMessageDecoder&I,O&
implements &I&
嵌套类概要
从接口继承的嵌套类/接口&io.netty.channel.
构造器概要
构造器和说明
(java.lang.Class&?&...&acceptedMsgTypes)&
限定符和类型
方法和说明
Invoked when this handler is not going to receive any inbound message anymore and thus it's safe to
deallocate its inbound buffer.
Does nothing by default.
(java.lang.Object&msg)
Returns true if and only if the specified message can be decoded by this decoder.
Return the
which will be used for inbound data to store.
从类继承的方法&io.netty.channel.
, , , , , , , , ,
从类继承的方法&java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法&io.netty.channel.
从接口继承的方法&io.netty.channel.
构造器详细资料
MessageToMessageDecoder
protected&MessageToMessageDecoder(java.lang.Class&?&...&acceptedMsgTypes)
方法详细资料
newInboundBuffer
public&&&&newInboundBuffer(&ctx)
throws java.lang.Exception
从接口复制的说明:&
Return the
which will be used for inbound data to store.
&在接口中&
&在接口中&&&
java.lang.Exception
freeInboundBuffer
public&void&freeInboundBuffer(&ctx,
throws java.lang.Exception
从接口复制的说明:&
Invoked when this handler is not going to receive any inbound message anymore and thus it's safe to
deallocate its inbound buffer.
&在接口中&
java.lang.Exception
inboundBufferUpdated
public&void&inboundBufferUpdated(&ctx)
throws java.lang.Exception
从类复制的说明:&
Does nothing by default. Sub-classes may override this if needed.
&在接口中&
java.lang.Exception
isDecodable
public&boolean&isDecodable(java.lang.Object&msg)
throws java.lang.Exception
Returns true if and only if the specified message can be decoded by this decoder.
参数:msg - the message
java.lang.Exception
public abstract&&decode(&ctx,
throws java.lang.Exception
java.lang.ExceptionJava Code Example io.netty.handler.codec.http.HttpObjectAggregator
Java Code Examples for io.netty.handler.codec.http.HttpObjectAggregator
The following are top voted examples for showing how to use
io.netty.handler.codec.http.HttpObjectAggregator. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
public void initChannel(SocketChannel ch)
String thrName = Thread.currentThread().getName() + &: &;
m_log.debug(thrName + &Initializing SocketChannel...&);
ChannelPipeline p = ch.pipeline();
//HttpMessage encoder/decoder
p.addLast(&httpDecoder&, new HttpRequestDecoder());
p.addLast(&httpAggr&, new HttpObjectAggregator(_httpBufferSize));
p.addLast(&httpEncoder&, new HttpResponseEncoder());
//Rocksdb encoder/decoder
p.addLast(&rocksdbDecoder&, new RocksdbQueryDecoder());
p.addLast(&rocksdbEncoder&, new RocksdbQueryEncoder());
//Rocksdb query handler
p.addLast(&rocksdbHandler&, new RocksdbQueryHandler(m_connPool));
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new HttpServerCodec());
ch.pipeline().addLast(new HttpObjectAggregator(1024 * 10));
ch.pipeline().addLast(new AutoCloseHandler());
ch.pipeline().addLast(new HttpResponseDecorator());
ch.pipeline().addLast(monitoringHandler);
ch.pipeline().addLast(new HttpCatchAllHandler());
protected void initChannel(SocketChannel channel) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(new WeixinMessageDecoder(aesTokenMap));
pipeline.addLast(new WeixinResponseEncoder());
pipeline.addLast(new SingleResponseEncoder());
pipeline.addLast(new WeixinRequestHandler(messageDispatcher));
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
Channel channel = ctx.channel();
if (msg instanceof HttpRequest) {
HttpRequest request = (HttpRequest)
if (handleRequest(request, channel, ctx)) {
if (httpMethodInfoBuilder.getHttpResourceModel()
.isStreamingReqSupported() &&
channel.pipeline().get(&aggregator&) != null) {
channel.pipeline().remove(&aggregator&);
} else if (!httpMethodInfoBuilder.getHttpResourceModel()
.isStreamingReqSupported() &&
channel.pipeline().get(&aggregator&) == null) {
channel.pipeline().addAfter(&router&, &aggregator&,
new HttpObjectAggregator(Integer.MAX_VALUE));
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
} else if (msg instanceof HttpContent) {
ReferenceCountUtil.retain(msg);
ctx.fireChannelRead(msg);
protected void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&decoder&, new HttpServerCodec());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(1048576));
pipeline.addLast(&streamer&, new ChunkedWriteHandler());
if (useHttpCompression) {
pipeline.addLast(&deflater&, new HttpContentCompressor());
pipeline.addLast(&handler&, new HttpFormattedHandler());
public ChannelFuture start() throws Exception {
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
.handler(new ))
.childHandler(new ChannelInitializer&SocketChannel&() {
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&httpRequestDecoder&, new HttpRequestDecoder());
pipeline.addLast(&httpResponseEncoder&, new HttpResponseEncoder());
pipeline.addLast(&httpChunkAggregator&, new HttpObjectAggregator(MAX_CONTENT_LENGTH));
pipeline.addLast(&httpRequestHandler&, new Http1RequestHandler());
Channel ch = b.bind(PORT).sync().channel();
return ch.closeFuture();
public void test() throws Exception {
given(engineProvider.get()).willReturn(engine);
given(ch.pipeline()).willReturn(pipeline);
given(pipeline.addLast(anyString(), any(ChannelHandler.class))).willReturn(pipeline);
hsci.initChannel(ch);
InOrder i = inOrder(pipeline);
i.verify(pipeline).addLast(eq(Decoder.toString()), isA(HttpRequestDecoder.class));
i.verify(pipeline).addLast(eq(Aggregator.toString()), isA(HttpObjectAggregator.class));
i.verify(pipeline).addLast(eq(Encoder.toString()), isA(HttpResponseEncoder.class));
i.verify(pipeline).addLast(eq(ChunkedWriter.toString()), isA(ChunkedWriteHandler.class));
i.verify(pipeline).addLast(JJEngine.toString(), engine);
// this test acts as an inventory of the handlers, so
// ensure nothing else happened
verifyNoMoreInteractions(pipeline);
public void run()
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup);
b.channel(NioServerSocketChannel.class);
b.childHandler(new ChannelInitializer&SocketChannel&()
public void initChannel(SocketChannel ch) throws Exception
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&codec-http&, new HttpServerCodec());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(65536));
pipeline.addLast(&handler&,
new WebSocketServerHandler(UpdateServer.this));
Channel ch = b.bind(port).sync().channel();
(&Web socket server started at port & + port + '.');
ch.closeFuture().sync();
catch (Exception e)
logger.error(&Update server broke&, e);
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&decoder&, new HttpRequestDecoder());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(65536));
pipeline.addLast(&deflater&, new HttpContentCompressor());
pipeline.addLast(&encoder&, new HttpResponseEncoder());
pipeline.addLast(&streamer&, new ChunkedWriteHandler());
pipeline.addLast(&handler&, new HttpSocketServerHandler());
Example 10
public static void main(String[] args) {
EventLoopGroup group = new NioEventLoopGroup();
URI uri = new URI(&http://192.168.0.194:8088/&);
Bootstrap b = new Bootstrap();
String protocol = uri.getScheme();
if (!&http&.equals(protocol)) {
throw new IllegalArgumentException(&Unsupported protocol: & + protocol);
final HttpClientHandler handler = new HttpClientHandler();
b.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer&SocketChannel&() {
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&http-codec&, new HttpClientCodec());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(8192));
pipeline.addLast(&http-handler&, handler);
System.out.println(&HTTP Client connecting&);
Channel ch = b.connect(uri.getHost(), uri.getPort()).sync().channel();
HttpRequest request = new DefaultHttpRequest(
HttpVersion.HTTP_1_1, HttpMethod.GET, &/ari/asterisk/info?api_key=admin:admin&);
request.headers().set(HttpHeaders.Names.HOST, &localhost&);
request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
ch.writeAndFlush(request);
ch.closeFuture().sync();
} catch (Exception e) {
e.printStackTrace();
} finally {
group.shutdownGracefully();
Example 11
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// Flash policy file
if (isFlashSupported) {
pipeline.addLast(FLASH_POLICY_HANDLER, flashPolicyHandler);
if (sslContext != null) {
SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setUseClientMode(false);
SslHandler sslHandler = new SslHandler(sslEngine);
//sslHandler.setIssueHandshake(true);
pipeline.addLast(SSL_HANDLER, sslHandler);
pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder());
pipeline.addLast(HTTP_CHUNK_AGGREGATOR, new HttpObjectAggregator(MAX_HTTP_CONTENT_LENGTH));
pipeline.addLast(HTTP_REPONSE_ENCODER, new HttpResponseEncoder());
// Flash resources
if (isFlashSupported) {
pipeline.addLast(FLASH_RESOURCE_HANDLER, flashResourceHandler);
// Socket.IO
pipeline.addLast(SOCKETIO_PACKET_ENCODER, packetEncoderHandler);
pipeline.addLast(SOCKETIO_HANDSHAKE_HANDLER, handshakeHanler);
pipeline.addLast(SOCKETIO_DISCONNECT_HANDLER, disconnectHanler);
pipeline.addLast(SOCKETIO_WEBSOCKET_HANDLER, webSocketHandler);
pipeline.addLast(SOCKETIO_FLASHSOCKET_HANDLER, flashSocketHandler);
pipeline.addLast(SOCKETIO_XHR_POLLING_HANDLER, xhrPollingHanler);
pipeline.addLast(SOCKETIO_JSONP_POLLING_HANDLER, jsonpPollingHanler);
pipeline.addLast(SOCKETIO_HEARTBEAT_HANDLER, heartbeatHandler);
pipeline.addLast(executorGroup, SOCKETIO_PACKET_DISPATCHER, packetDispatcherHandler);
Example 12
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpObjectAggregator(1048576));
pipeline.addLast(new HttpResponseEncoder());
pipeline.addLast(new HttpApiRequestHandler(instance));
Example 13
private void initialize(){
String protocol = uri.getScheme();
if (!&http&.equals(protocol)) {
throw new IllegalArgumentException(&Unsupported protocol: & + protocol);
bootstrap.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer&SocketChannel&() {
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(&http-codec&, new HttpClientCodec());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(8192));
pipeline.addLast(&ws-handler&, clientHandler);
Example 14
protected ChannelPipeline getDefaulHttpChannelPipeline(Channel channel) throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = channel.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
LOG.log(Level.FINE,
&Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}&,
sslHandler);
pipeline.addLast(&ssl&, sslHandler);
pipeline.addLast(&decoder&, new HttpRequestDecoder());
pipeline.addLast(&aggregator&, new HttpObjectAggregator(maxChunkContentSize));
pipeline.addLast(&encoder&, new HttpResponseEncoder());
// Remove the following line if you don't want automatic content
// compression.
pipeline.addLast(&deflater&, new HttpContentCompressor());
// Set up the idle handler
pipeline.addLast(&idle&, new IdleStateHandler(nettyHttpServerEngine.getReadIdleTime(),
nettyHttpServerEngine.getWriteIdleTime(), 0));
Example 15
public void initialize() {
(&Initializing the connector&);
EventLoopGroup bossGroup = new NioEventLoopGroup(configuration.getIoWorkerThreadCount());
EventLoopGroup workerGroup = new NioEventLoopGroup(configuration.getIoWorkerThreadCount());
bootstrap = new ServerBootstrap();
bootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG, 100)
.childOption(ChannelOption.TCP_NODELAY, true)
.childHandler(new ChannelInitializer&SocketChannel&() {
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new HttpRequestDecoder(), new HttpResponseEncoder(), new HttpObjectAggregator(configuration.getMaxContentLength()), AbstractHttpConnector.this);
addChannelHandlers(ch.pipeline());
Example 16
public void connect(int port) throws Exception {
// ?????NIO???
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap b = new Bootstrap();
b.group(group).channel(NioSocketChannel.class)
.option(ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer&SocketChannel&() {
public void initChannel(SocketChannel ch)
throws Exception {
ch.pipeline().addLast(&http-decoder&,
new HttpResponseDecoder());
ch.pipeline().addLast(&http-aggregator&,
new HttpObjectAggregator(65536));
ch.pipeline().addLast(
&xml-decoder&,
new HttpXmlResponseDecoder(Order.class,
ch.pipeline().addLast(&http-encoder&,
new HttpRequestEncoder());
ch.pipeline().addLast(&xml-encoder&,
new HttpXmlRequestEncoder());
ch.pipeline().addLast(&xmlClientHandler&,
new HttpXmlClientHandle());
// ????????
ChannelFuture f = b.connect(new InetSocketAddress(port)).sync();
// ?????????
f.channel().closeFuture().sync();
} finally {
// ???????NIO???
group.shutdownGracefully();
Example 17
public void start() {
final ErraiServiceConfigurator esc = svc.getConfiguration();
useSecureWebSocket = ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(esc);
final int port = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(esc);
final ServerBootstrap bootstrap = new ServerBootstrap();
final WebSocketServerHandler webSocketHandler = new WebSocketServerHandler(svc);
final NioEventLoopGroup bossGroup = new NioEventLoopGroup();
final NioEventLoopGroup workerGroup = new NioEventLoopGroup();
final ChannelFuture channelFuture = bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer() {
protected void initChannel(Channel ch) throws Exception {
if (useSecureWebSocket) {
final SslHandler sslHandler = SslHandlerFactory.buildSslHandler(esc);
ch.pipeline().addLast(&ssl&, sslHandler);
ch.pipeline().addLast(&codec-http&, new HttpServerCodec());
ch.pipeline().addLast(&aggregator&, new HttpObjectAggregator(65536));
ch.pipeline().addLast(&handler&, webSocketHandler);
}).bind(port).sync();
svc.addShutdownHook(new Runnable() {
public void run() {
webSocketHandler.stop();
channelFuture.channel().close();
(&web socket server stopped.&);
catch (Exception e) {
throw new RuntimeException(e);
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
catch (Throwable t) {
throw new RuntimeException(t);
(&started web socket server on port: & + port);
Example 18
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
boolean isSsl = Boolean.getBoolean(&kinetic.io.https&);
if (isSsl) {
SSLEngine engine = SslContextFactory.getServerContext()
.createSSLEngine();
engine.setUseClientMode(false);
p.addLast(&ssl&, new SslHandler(engine));
(&ssl handler added, https is enabled ...&);
p.addLast(&decoder&, new HttpRequestDecoder(1024, 4 * 1024,
4 * 1024 * 1024));
p.addLast(&encoder&, new HttpResponseEncoder());
p.addLast(&aggregator&, new HttpObjectAggregator(4 * 1024 * 1024));
p.addLast(&handler&, new HttpMessageServiceHandler(lcservice));
(&http channel initialized. ssl/tls enabled=& + isSsl);
Example 19
private void createChannelPipeline() {
if (isPipelineCreated())
m_workerGroup = new NioEventLoopGroup(getConfig().getNumWorkers(), new NameableThreadFactory(&Jetstream-HttpClientWorker&));
m_bootstrap = new Bootstrap();
m_bootstrap.group(m_workerGroup).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, false)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
getConfig()
.getConnectionTimeoutInSecs())
.handler(new ChannelInitializer&SocketChannel&() {
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(&timeout&, new IdleStateHandler(0, getConfig().getIdleTimeoutInSecs(), 0));
ch.pipeline().addLast(&decoder&, new HttpResponseDecoder());
ch.pipeline().addLast(&decompressor&, new HttpContentDecompressor());
ch.pipeline().addLast(&encoder&, new HttpRequestEncoder());
ch.pipeline().addLast(&aggregator&, new HttpObjectAggregator(m_config.getMaxContentLength()));
ch.pipeline().addLast(m_httpRequestHandler);
if (getConfig().getRvcBufSz() & 0) {
m_bootstrap.option(ChannelOption.SO_RCVBUF, (int) getConfig().getRvcBufSz());
if ( getConfig().getSendBufSz() & 0) {
m_bootstrap.option(ChannelOption.SO_SNDBUF, (int) getConfig().getSendBufSz());
createdPipeline();
Example 20
private Bootstrap createBootstrap() {
return new Bootstrap().channel(NioSocketChannel.class) //
.group(clientGroup).option(ChannelOption.TCP_NODELAY, true) //
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000) //
.handler(new ChannelInitializer&SocketChannel&() {
protected void initChannel(SocketChannel channel)
throws Exception {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(&codec&, new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(1048576));
pipeline.addLast(buildProcessor(serializer));

我要回帖

更多关于 java internalframe 的文章

 

随机推荐