public override async Task <int> ReadAsync(byte[] buffer, int offset, int length,
                                                   CancellationToken cancellationToken)
        {
            //TODO: investigate how it should work correctly
            CheckNotDisposed();

            ValidateBufferArgs(buffer, offset, length);

            if (!IsOpen)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen);
            }

            if (_inputBuffer.Capacity < _bufSize)
            {
                _inputBuffer.Capacity = _bufSize;
            }

            var got = await _inputBuffer.ReadAsync(buffer, offset, length, cancellationToken).ConfigureAwait(false);

            if (got > 0)
            {
                return(got);
            }

            _inputBuffer.Seek(0, SeekOrigin.Begin);
            _inputBuffer.SetLength(_inputBuffer.Capacity);

            ArraySegment <byte> bufSegment;

            _inputBuffer.TryGetBuffer(out bufSegment);

            // investigate
            var filled = await _transport.ReadAsync(bufSegment.Array, 0, (int)_inputBuffer.Length, cancellationToken).ConfigureAwait(false);

            _inputBuffer.SetLength(filled);

            if (filled == 0)
            {
                return(0);
            }

            return(await ReadAsync(buffer, offset, length, cancellationToken).ConfigureAwait(false));
        }