Seeing data corruption when using ChannelHandlerContext.set/getAttachement API
brunodecarvalho
kindernade at gmail.com
Tue Jul 20 21:28:05 EDT 2010
Greg,
You're using a pipeline rather than a pipeline factory.
A pipeline factory will create a new pipeline for each new channel (perhaps
that's why your getAttachment() was acting weirdly) whereas your code will
use the exact same pipeline for all the connections. The logical result is
that all channels will share the same ServerHandler instance.
Here's what you want (compare with your code, you'll notice the difference):
ChannelPipeline pipeline = bootstrap.setPipelineFactory(new
ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
// Add the text line codec combination first,
pipeline.addLast("framer", ...);
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
// Set up the default event pipeline.
pipeline.addLast("handler", new ServerHandler());
return pipeline;
}
});
Now that I think of it, I'm surprised both the framer and decoder worked out
well... You must have been testing client and server in the same machine,
right?
Cheers,
Bruno
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Seeing-data-corruption-when-using-ChannelHandlerContext-set-getAttachement-API-tp5318952p5319262.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list