Q:

dynamic ChannelHandler to use different protocols

I want to implement a netty server that uses a websocket sub protocol to connect to browser clients. I also want some other clients to talk with the same sub protocoll via a tcp connection because they are no browsers and on the same machine/network as the server. This should increase the performance.
My problem is that it seems not possible to add a ChannelHandler by detecting the protocol used by the client. Is there a way I couldn't find or do I need to implement two separate servers and connect with different ports?

A:

Either you implement 2 different ServerBootstrap using 2 different ports and then 2 different protocols
Either you have to find a way to detect what kind of protocol is used using the very first message and then adapting your pipeline accordingly dynamically: 

this would lead to have a "2-way (or more) protocols" detector in your pipeline, having no other handler in your pipeline at first time
then this detector will decide according to the very first message which handlers are needed and add them in the pipeline, send the message to the next handler (new one) and remove itself from the pipeline once the message is forwarded

