title: MQTT over WebSockets using Netty?
body: <p>I want to use MQTT over Websockets. In Netty using Websockets is quite easy:</p>
  
  <pre><code>ChannelPipeline pipeline = ch.pipeline();
  pipeline.addLast("codec-http", new HttpServerCodec());
  pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
  pipeline.addLast("handler", new WebSocketServerHandler());
  </code></pre>
  
  <p>I've found MQTT broker  (moquette)  which is based on Netty. </p>
  
  <pre><code> NettyMQTTHandler handler = new NettyMQTTHandler();
   ServerBootstrap b = new ServerBootstrap();
              b.group(m_bossGroup, m_workerGroup)
               .channel(NioServerSocketChannel.class) 
               .childHandler(new ChannelInitializer&lt;SocketChannel&gt;() { 
                   @Override
                   public void initChannel(SocketChannel ch) throws Exception {
                      ChannelPipeline pipeline = ch.pipeline();
                      //pipeline.addFirst("metrics", new BytesMetricsHandler(m_metricsCollector));
                      pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, Constants.DEFAULT_CONNECT_TIMEOUT));
                      pipeline.addAfter("idleStateHandler", "idleEventHandler", new MoquetteIdleTimoutHandler());
                      //pipeline.addLast("logger", new LoggingHandler("Netty", LogLevel.ERROR));
                      pipeline.addLast("decoder", new MQTTDecoder());
                      pipeline.addLast("encoder", new MQTTEncoder());
                      pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
                      pipeline.addLast("handler", handler);
                   }
               })
               .option(ChannelOption.SO_BACKLOG, 128)
               .option(ChannelOption.SO_REUSEADDR, true)
               .childOption(ChannelOption.SO_KEEPALIVE, true); 
  </code></pre>
  
  <p>So in the theory I should be able to send MQTT over Websocket but I have no idea if it possible using Netty? Does any have any clues or ideas how to do that? Should I use MessageToMessageCodec  and BinaryWebSocketFrame?</p>
  
  <p>Cheers!</p>