title: Android Netty 4 Client
body: <p>I try to create a simple tcp/ip client on Android with <code>Netty 4</code>. Now it working fine, but I have a problem with reconnect if device lost connection and get it again. 
  My client code:</p>
  
  <pre><code>public class Client {
  
      private EventLoopGroup group;
      public static Bootstrap b;
  
      public void run() throws Exception {
          group = new NioEventLoopGroup();
          b = new Bootstrap();
          b.group(group)
                  .channel(NioSocketChannel.class)
                  .handler(new ClientInitializer(b));
          b.option(ChannelOption.SO_KEEPALIVE, true);
      }
  
      public void startConnection(){
          try {
              b.connect(Constants.HOSTNAME, Constants.PORT).sync().channel();
          } catch (Exception e) {
              Log.e(TAG, e.getMessage());
          }
      }
  
      public void closeConnection () throws Exception{
          group.shutdownGracefully();
      }
  }
  </code></pre>
  
  <p>In activity through receiver I detect internet connection and if internet available I do next action:</p>
  
  <p><code>Client.b.connect(Constants.HOSTNAME, Constants.PORT);</code></p>
  
  <p>But new connection can't see server. What I am do wrong? May be all my way to do it wrong? </p>