Howto get some ID for a Netty Channel? -


channel.id() has been removed in netty 4.0.0.cr9.

how id of channel these days?

i used use id() logging purposes in handlers (e.g. system.out.println(ctx.channel().id() + " - readablebytes(): " + in.readablebytes())).

i cannot rely on tostring method of channel because might overridden.

if sure channel active, can generate unique id of channel combining hashcode(), remoteaddress(), , localaddress(). alternatively, can use channel.tostring() generates string 3 properties. if channel not active yet, remoteaddress() , localaddress() not give meaningful information, still @ risk of collision.

netty 4.1 , 5.0 re-introduced channel.id(), returns new type called channelid. uses various information such mac address, current pid, timestamp, , hashcode, can used globally unique id. check javadoc.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -