UDP - NotYetConnectedException
"Trustin Lee (이희승)"
trustin at gmail.com
Fri Jan 8 18:11:47 EST 2010
fps wrote:
> Hi
>
> I've got a server running using Netty and UDP (NIO).
> I can send a simple UDP packet to the server which is received and processed
> correctly. Part of the processing send a reply to the client but when
> sending the reply I get a NotYetConnectedException...
>
>
> java.nio.channels.NotYetConnectedException
> at sun.nio.ch.DatagramChannelImpl.write(DatagramChannelImpl.java:378)
> at
> org.jboss.netty.buffer.HeapChannelBuffer.getBytes(HeapChannelBuffer.java:119)
> at
> org.jboss.netty.channel.socket.nio.NioDatagramWorker.writeNow(NioDatagramWorker.java:523)
> at
> org.jboss.netty.channel.socket.nio.NioDatagramWorker.write(NioDatagramWorker.java:457)
> at
> org.jboss.netty.channel.socket.nio.NioDatagramPipelineSink.eventSunk(NioDatagramPipelineSink.java:112)
> at org.jboss.netty.channel.Channels.write(Channels.java:608)
> at org.jboss.netty.channel.Channels.write(Channels.java:569)
> at
> com.jitty.proxy.server.handlers.MyEncoder.writeRequested(MyEncoder.java:39)
>
> My client is non-Netty and pretty simple:
> ds = new DatagramSocket();
> ds.connect("127.0.0.1", 50000);
> byte[] send = ...
> ds.send(new DatagramPacket(send, send.length));
> // then wait for udp packet from server
> byte[] receive = new byte[1400];
> ds.receive(new DatagramPacket(receive, receive.length));
>
> Why do you I get this NotYetConnectedException when replying to a client
> that has just sent a message.?
It's because your server side Netty UDP channel is not connected, but
just bound. As stated in the Javadoc of Channel.write(Object), you
should use Channel.write(Object, SocketAddress), if you are writing to
an unconnected channel.
HTH,
Trustin
> Note that I have the same processing over TCP (NIO) which works great.
>
> Thx
> Frederic
--
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/20100109/bd2f883e/attachment.bin
More information about the netty-users
mailing list