Multicast receiver issue

Davide Rossoni rossoni.davide at gmail.com
Tue Nov 10 11:25:44 EST 2009


I'm trying to adopt Netty in order to re-implement my Multicast Sender and
Receiver.

It works fine with the MulticastSender using Netty with old blocking I/O,
but I spent three days trying to understand how to implements the
MulticastReceiver: I did not receive any multicast message.

Please note that using a simple java MulticastSocket implementation it works
very well, and I receive data sent from the Netty-MulticastSender.

Could you help me?

Here an extract of my Receiver class:

DatagramChannelFactory datagramChannelFactory = new
OioDatagramChannelFactory(Executors.newCachedThreadPool());

ConnectionlessBootstrap connectionlessBootstrap = new
ConnectionlessBootstrap(datagramChannelFactory);
ChannelPipeline channelPipeline = connectionlessBootstrap.getPipeline();

channelPipeline.addLast("handler", new MulticastReceiverHandler());

connectionlessBootstrap.setOption("receiveBufferSize", receiveBufferSize);
connectionlessBootstrap.setOption("sendBufferSize", sendBufferSize);
connectionlessBootstrap.setOption("trafficClass", trafficClass);
connectionlessBootstrap.setOption("soTimeout", soTimeout);
connectionlessBootstrap.setOption("broadcast", broadcast);
connectionlessBootstrap.setOption("loopbackMode", loopbackMode);
connectionlessBootstrap.setOption("reuseAddress", reuseAddress);

DatagramChannel datagramChannel = (DatagramChannel)
connectionlessBootstrap.bind(new InetSocketAddress(172.26.16.20, 0));

InetSocketAddress multicastAddress = new InetSocketAddress(228.10.10.10,
2222);
NetworkInterface networkInterface =
NetworkInterface.getByInetAddress(InetAddress.getByName(PriceFeederHelper.multicastNIC));
datagramChannel.joinGroup(multicastAddress, networkInterface);



Here my ReceiverHandler class:

@ChannelPipelineCoverage("all")
public class MulticastReceiverHandler extends SimpleChannelHandler {

       private final Logger logger = LoggerFactory.getLogger(getClass());

       @Override
       public void messageReceived(ChannelHandlerContext ctx, MessageEvent
e) throws Exception {
               logger.info("message = " + e.getMessage());

               ctx.sendUpstream(e);
       }

       @Override
       public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
e) throws Exception {
               logger.error("Unexpected exception from downstream.",
e.getCause());
               e.getChannel().close();

               super.exceptionCaught(ctx, e);
       }

}

-- 
View this message in context: http://n2.nabble.com/Multicast-receiver-issue-tp3980856p3980856.html
Sent from the Netty Developer Group mailing list archive at Nabble.com.


More information about the netty-dev mailing list