// of data or the handshake is finished
while (buf.hasRemaining() && !handler.isHandshakeComplete()) {
logger.debug(" Pre-handshake - passing to handler");
int pos = buf.position();
handler.messageReceived(nextFilter, buf);
// Data not consumed or session closing
if (buf.position() == pos || session.isClosing()) {
return;
}