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

  • 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)
    ...
  • To resolve this issue, consider the following workaround:

    • Open the Web.config file of the xConnect instance.
    • Increase the value of the maxRequestLength attribute. Note that the maximum allowed value is "2147483647", but it is preferable to use a smaller value. For example, change:
      <system.web>
          <compilation debug="true" targetFramework="4.7.1" />
          <httpRuntime targetFramework="4.7.1" maxRequestLength="1048576" maxUrlLength="8192" maxQueryStringLength="8192" requestPathInvalidCharacters="" />
          <customErrors mode="RemoteOnly" />
        </system.web>
      to
      <system.web>
          <compilation debug="true" targetFramework="4.7.1" />
          <httpRuntime targetFramework="4.7.1" maxRequestLength="2147483647" maxUrlLength="8192" maxQueryStringLength="8192" requestPathInvalidCharacters="" />
          <customErrors mode="RemoteOnly" />
        </system.web>

Applies to:

CMS 9.1 Update-1+

March 16, 2020
March 16, 2020

Reference number:

182928