title: Disabling HTTP protocol requests within Netty?
body: <p>I'm writing a game server in Java, and I'm using Netty 3.6.2. The game servers should accept no HTTP requests, as they simply handle game client data (which is purely bytes over TCP). When I load <a href="http://server-ip:game-servers-port" rel="nofollow">http://server-ip:game-servers-port</a> in Chrome, I download a file with the game's handshake packet (which should not happen).</p>
  
  <p>I bind to the game server's port like so:</p>
  
  <pre><code>ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
  clientAcceptor = new ServerBootstrap(factory);
  
  clientAcceptor.setOption("child.tcpNoDelay", true);
  clientAcceptor.setOption("child.keepAlive", false);
  
  clientAcceptor.setPipelineFactory(() -&gt; Channels.pipeline(new PacketDecoder(), new ClientHandler()));
  
  clientAcceptor.bind(new InetSocketAddress(Configurations.CHANNEL_GAME_PORT));
  </code></pre>
  
  <p>And I process requests in a SimpleChannelHandler, like so</p>
  
  <pre><code>@Override
  public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
      // Encryption key code.
  
      Packets.sendHello(ctx.getChannel(), ivRecv, ivSend);
  
      ctx.getChannel().setAttachment(client);
  }
  </code></pre>
  
  <p>How can I go about deciphering if an incoming request is using the HTTP protocol?</p>
  
  <p>Edit: I should also say, it should also block any FTP, WebSocket, etc. protocol (essentially anything that isn't the game's protocol) on channel connect.</p>