Error in xConnect log about maximum number of bytes allowed to be read from the stream


Description

Sending xConnect requests might fail with an unhandled exception when the request size exceeds the value of the maxRequestLength attribute in the Web.config file. For example, if a visitor has visited too many pages, triggered too many goals, and a huge visit record is submitted to xConnect. The following message can be found in the log records:

[Error] XConnect Exception Logger LogAsync()
Microsoft.OData.ODataException: The maximum number of bytes allowed to be read from the stream has been exceeded. After the last read operation, a total of 1055995 bytes has been read from the stream; however a maximum of 1048576 bytes is allowed.
   at Microsoft.OData.MessageStreamWrapper.MessageStreamWrappingStream.IncreaseTotalBytesRead(Int32 bytesRead)
   at Microsoft.OData.MessageStreamWrapper.MessageStreamWrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
...

Solution

To resolve this issue, consider the following workaround: