Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

setTimeToLive fails in netty 4 java 7 nio config #313

Closed
carrot-garden opened this Issue · 2 comments

2 participants

@carrot-garden

setTimeToLive fails here:

https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java#L255

@Override
public void setTimeToLive(int ttl) {
    if (socket instanceof MulticastSocket) {
        try {
            ((MulticastSocket) socket).setTimeToLive(ttl);
        } catch (IOException e) {
            throw new ChannelException(e);
        }
    } else {
        throw new UnsupportedOperationException();
    }
}

due to actual socket instance being

sun.nio.ch.DatagramSocketAdaptor NOT MulticastSocket

test code

https://github.com/barchart/barchart-netty-zoom/blob/master/barchart-netty-host/src/test/java/com/barchart/netty/host/MainServiceHost.java

stack tarace

java.lang.UnsupportedOperationException
at io.netty.channel.socket.DefaultDatagramChannelConfig.setTimeToLive(DefaultDatagramChannelConfig.java:261)
at io.netty.channel.socket.DefaultDatagramChannelConfig.setOption(DefaultDatagramChannelConfig.java:80)
at io.netty.channel.socket.nio.DefaultNioDatagramChannelConfig.setOption(DefaultNioDatagramChannelConfig.java:70)
at io.netty.channel.DefaultChannelConfig.setOptions(DefaultChannelConfig.java:37)
at io.netty.channel.socket.nio.DefaultNioDatagramChannelConfig.setOptions(DefaultNioDatagramChannelConfig.java:54)
at io.netty.bootstrap.ConnectionlessBootstrap.bind(ConnectionlessBootstrap.java:188)
at com.barchart.netty.host.DatagramConduit.start(DatagramConduit.java:72)
at com.barchart.netty.host.ServiceHost.start(ServiceHost.java:49)
at com.barchart.netty.host.MainServiceHost.main(MainServiceHost.java:61)

@normanmaurer normanmaurer was assigned
@normanmaurer
Collaborator

fixed.. Also fixed other config options + added a testcase. Thanks!

@carrot-garden

thank you. there is another problem : please see #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.