Repository navigation
Closed
Description
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?
Activity
normanmaurer commentedon Sep 10, 2012
Thats a bug.. I will look into this.
Sent from my iPhone. Excuse any typos....
Am 10.09.2012 um 16:16 schrieb Frédéric Brégier [email protected]:
normanmaurer commentedon Sep 11, 2012
@fredericBregier please check #594 and let me know what you think..
fredericBregier commentedon Sep 11, 2012
@normanmaurer I just check right now (from the branch bootstrap_refactor) with the very same example, and now it works.
From the log, I obtain the following :
The corresponding code (end of Echo client) is as follow:
So my question is : is it normal that logging shows INACTIVE and UNREGISTERED "after" the logging "Start retry connect" while it is after a closeFuture().sync() ? There is no arm there, but I just want to know if for you it is ok ?
normanmaurer commentedon Sep 12, 2012
Need to check… But at least it works :)
What do you think about the changes ? Do you think they still provide a nice fluent api for bootstrapping ?
Am 11.09.2012 um 18:56 schrieb Frédéric Brégier [email protected]:
fredericBregier commentedon Sep 12, 2012
As far as I test it, It is ok.
Concerning the name, it is at least consistent with previous API (3.X) from the name point of view.
normanmaurer commentedon Sep 12, 2012
Well with 3.x you would have used ConnectionlessBootstrap ;)
2012/9/12 Frédéric Brégier [email protected]
Update action versions (netty#591)