Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error Codes] Updated MessageTooLarge #2073

Merged
merged 4 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Microsoft.Azure.Devices.Client.Exceptions
/// <summary>
/// The exception that is thrown when an attempt to send a message fails because the length of the message exceeds the maximum size allowed.
/// </summary>
/// <remarks>
/// When the message is too large for IoT Hub you will receive this exception. You should attempt to reduce your message size and send again. For more information on message sizes, see <see href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling#other-limits">IoT Hub quotas and throttling | Other limits</see>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We recently learned that we can get 2 different errors depending on how large the message is. Meaning, if > 1MB, we get a different one, and if too large but < 1MB we get this one.

It might be worth noting that. @abhipsaMisra has more info, IIRC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, we did have this behavior which has now been fixed in master: #2053. We'll now see MessageTooLargeException for all message sizes over 256kb limit then sent via AMQP/HTTP.
MQTT , however, will perform a client-level validation and throw an InvalidOperationException instead. This would be worth calling out:

throw new InvalidOperationException($"Message size ({streamLength} bytes) is too big to process. Maximum allowed payload size is {MaxPayloadSize}");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, just to keep things clean we should probably not mention this exception because they are only related by the concept of message size. A customer who is getting the MessageTooLargeException wouldn't need to know about the other limit.

We probably should have repurposed this exception for the >1MB issue.

/// </remarks>
[Serializable]
public sealed class MessageTooLargeException : IotHubException
{
Expand Down
5 changes: 4 additions & 1 deletion iothub/service/src/Common/Exceptions/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public enum ErrorCode
DeviceMessageLockLost = 412002,

// RequestEntityTooLarge - 413
/// <summary>
/// When the message is too large for IoT Hub you will receive this error. You should attempt to reduce your message size and send again. For more information on message sizes, see <see href="https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-quotas-throttling#other-limits">IoT Hub quotas and throttling | Other limits</see>
/// </summary>
MessageTooLarge = 413001,

TooManyDevices = 413002,
Expand All @@ -98,7 +101,7 @@ public enum ErrorCode

/// <summary>
/// IoT hub throttling limits have been exceeded for the requested operation.
/// For more information, <see href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling"/>
/// For more information, <see href="https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-quotas-throttling"/>
/// </summary>
ThrottlingException = 429001,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
namespace Microsoft.Azure.Devices.Common.Exceptions
{
/// <summary>
/// The exception that is thrown when a message is sent to IoT Hub that exceeds the maximum allowed bytes in size.
/// The exception that is thrown when an attempt to send a message fails because the length of the message exceeds the maximum size allowed.
/// </summary>
/// <remarks>
/// When the message is too large for IoT Hub you will receive this exception. You should attempt to reduce your message size and send again. For more information on message sizes, see <see href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling#other-limits">IoT Hub quotas and throttling | Other limits</see>
/// </remarks>
[Serializable]
public sealed class MessageTooLargeException : IotHubException
{
Expand Down