Resolve bidirectional invoking between sendMessage and drainBuffer.