title: Netty shutdown/Stop UDP server
body: <p>I'm trying to create Netty UDP listener. The problem I faced is that I can't stop udp server like tcp, the udp always is running, even with shutdowngracefully called, the only way to stop it is by throwing exception.</p>
  
  <pre><code>private int port;
  private UDPViewModel viewModel;
  private DefaultEventLoopGroup defaultEventLoopGroup;
  
  public UdpServer(UDPViewModel viewModel, int port) {
     this.port = port;
     this.viewModel = viewModel;
  }
  
  @Override
  public void run() {
      defaultEventLoopGroup = new DefaultEventLoopGroup();
      try {
  
          ServerBootstrap bootstrap = new ServerBootstrap()
                  .channel(UdpServerChannel.class)
                  .group(defaultEventLoopGroup)
                  .childHandler(new ChannelInitializer&lt;Channel&gt;() {
                      @Override
                      protected void initChannel(Channel channel) {
                          channel.pipeline()
                                  .addLast(new ReadTimeoutHandler(5))
                                  .addLast(new UdpServerHandler(viewModel));
                      }
                  });
          bootstrap.bind(port).sync().channel().closeFuture().syncUninterruptibly().await();
  
          System.out.println("UDP Server : [successfully started]");
      } catch (InterruptedException e) {
          e.printStackTrace();
      } finally {
          defaultEventLoopGroup.shutdownGracefully();
      }
  }
  </code></pre>
  
  <p>Anyone has any ideas on how to shutdown netty udp server properly ?</p>