Hi,
Since Github is for the moment ouf of line, I post here my concern on Netty 4.
I try to get into it, and of course, while I am trying to convert Netty3 based code to Netty4, I try also the examples and check some functionalities.
One of the first I saw with an issue was also noted on the
https://netty.io/Documentation/New+and+Noteworthy page as one comment.
I take the Echo example, add in the server side a limit of "ping-ping" like this:
public void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) {
limit --;
if (limit > 0) {
ByteBuf out = ctx.nextOutboundByteBuffer();
out.discardReadBytes();
out.writeBytes(in);
ctx.flush();
} else {
// end
ctx.close();
}
}
Then in the client, I added the following at the end of the run method:
// Start the client. Original one
ChannelFuture f = b.connect().sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
// and now try to reconnect NEW Code
System.out.println("try to restart");
// Start the client.
f = b.connect().sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
And I get the following output:
sept. 10, 2012 4:06:03 PM io.netty.handler.logging.LoggingHandler
Infos: [id: 0xfedfd297] REGISTERED
sept. 10, 2012 4:06:03 PM io.netty.handler.logging.LoggingHandler
Infos: [id: 0xfedfd297, /
0.0.0.0:3780 => /
127.0.0.1:8080] ACTIVE
try to restart
Exception in thread "main" sept. 10, 2012 4:06:03 PM io.netty.handler.logging.LoggingHandler
Infos: [id: 0xfedfd297, /
0.0.0.0:3780 :> /
127.0.0.1:8080] INACTIVE
java.lang.IllegalStateException: channel already registered: [id: 0xfedfd297, /
0.0.0.0:3780 :> /
127.0.0.1:8080]
at io.netty.bootstrap.Bootstrap.init(Bootstrap.java:185)
at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:162)
at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:152)
at io.netty.example.echo.EchoClient.run(EchoClient.java:73)
at io.netty.example.echo.EchoClient.main(EchoClient.java:102)
sept. 10, 2012 4:06:03 PM io.netty.handler.logging.LoggingHandler
Infos: [id: 0xfedfd297, /
0.0.0.0:3780 :> /
127.0.0.1:8080] UNREGISTERED
Do I missed something in the logic?
I will come back later on with a "traffic" handler for Netty4 if I understand the first steps correctly...
Cheers,
Frederic