Description:
The test ReceiveMessage_should_throw_a_FormatException_when_message_is_an_invalid_size in BinaryConnectionTests.cs is failing on Big Endian architectures (e.g., s390x) with a TimeoutException instead of the expected FormatException.
This happens because the test uses BitConverter.GetBytes(length) to write the message size, which produces bytes in the system's native endianness. However, MongoDB's wire protocol expects all integers—including message length headers—to be encoded in little-endian format.
On Big Endian systems, the test writes the length in big-endian format, resulting in incorrect message size parsing in the driver, which then waits for more bytes than were sent, eventually timing out.
The source code (driver) handles this correctly by using BinaryPrimitives.ReadInt32LittleEndian, so the fault lies in the test setup, not in the driver implementation.