Channel.write(Object obj)
"Trustin Lee (이희승)"
trustin at gmail.com
Wed Jan 6 22:31:39 EST 2010
Hello Michael,
Could you post the stack trace of the UnsupportedOperationException?
MichaelW86 wrote:
> Hallo
> I'm trying to use Netty for a Socket Server but i have problems to write a
> message to the downstream channel. When i use the channel.write() Method the
> Exception: java.lang.UnsupportedOperationException is returned by the
> corresponding future.getCause() Method. I think i do something wrong...
>
> Here is the Server Code:
>
>
> /***********************************************************************************/
> /* Class NJServer */
>
> public class NJServer {
>
> public static void main(String[] args) throws Exception {
> new NJServer();
> }
>
> public NJServer() {
> this.factory = new NioServerSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool());
>
> this.bootstrap = new ServerBootstrap(factory);
>
> bootstrap.setPipelineFactory(new NJServerPipelineFactory());
>
> this.channel = bootstrap.bind(new InetSocketAddress(1234));
>
> allChannels.add(channel);
>
> byte commando = 1;
> [...]
>
> ChannelBuffer buf = ChannelBuffers.buffer(16);
> buf.writeByte(commando);
> [...]
>
> /* HERE IS THE PROBLEM */
> f = this.channel.write(buf);
>
> f.addListener(new ChannelFutureListener() {
> public void operationComplete(ChannelFuture future) {
> if (future.isSuccess()) { [...] }
> else { System.out.print(future.getCause()); }
> }
> });
>
> waitForShutdownCommand();
>
> [...]
> }
>
> }
>
> /* Class NJServerPipelineFactory */
> [...]
>
> pipeline.addLast("handler", new NJServerHandler());
>
> [...]
>
>
> /* Class NJServerHandler */
> [...]
>
> @Override
> public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
> e.getChannel().getPipeline().addFirst("encoder", new NJMessageEncoder());
> e.getChannel().getPipeline().addFirst("decoder", new NJMessageDecoder());
> }
>
> [...]
>
> /***********************************************************************************/
>
> The NJMessageEncoder is never called!! The NJMessageDecoder works. So whats
> the problem? The Client Application is a Java Socket Client, where Netty is
> not used.
>
> Thanks in advance!
>
> Michael
>
>
>
>
>
--
what we call human nature in actuality is human habit
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100107/b028463c/attachment.bin
More information about the netty-users
mailing list