Skip to content

Command Registration throws exception if a too big message was send before #3484

@bastiKamp

Description

@bastiKamp

Context

OS: Windows 11 Desktop x64
Application's .NET Target Framework : .NET 8.0 ASP.NET Core application
Device: Laptop
SDK version used: 1.42.3

Description of the issue

We have a problem with "RegisterCommandHandlerAsync" if we send a message with a too large message body before. The process order is this:

  1. Connect to IoT Hub
  2. Send a large message -> Exception throws (this is ok)
  3. Register command handler -> Exception throws (this should not throw)

Console log of the issue

System.InvalidOperationException: Message size (559135 bytes) is too big to process. Maximum allowed payload size is 262143
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.ComposePublishPacketAsync(IChannelHandlerContext context, Message message, QualityOfService qos, String topicName)
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.SendMessageAsync(IChannelHandlerContext context, Message message)
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.WriteAsync(IChannelHandlerContext context, Object data)
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.SubscribeAsync(IChannelHandlerContext context, SubscribePacket packetPassed)
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.WriteAsync(IChannelHandlerContext context, Object data)
   at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttTransportHandler.EnableMethodsAsync(CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.<>c__DisplayClass27_0.<<ExecuteWithErrorHandlingAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.ExecuteWithErrorHandlingAsync[T](Func`1 asyncOperation)
   at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.<>c__DisplayClass30_0.<<EnableMethodsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.<>c__DisplayClass34_0.<<RunWithRetryAsync>g__TaskWrapper|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.RunWithRetryAsync[T](Func`1 taskFunc, ShouldRetry shouldRetry, Func`2 isTransient, Action`3 onRetrying, Boolean fastFirstRetry, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.TransientFaultHandling.RetryPolicy.RunWithRetryAsync(Func`1 taskFunc, ShouldRetry shouldRetry, Func`2 isTransient, Action`3 onRetrying, Boolean fastFirstRetry, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.EnableMethodsAsync(CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.InternalClient.HandleMethodEnableAsync(CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Client.InternalClient.SetMethodHandlerAsync(String methodName, MethodCallback methodHandler, Object userContext, CancellationToken cancellationToken)
   at Deos.P126.Cloud.Gate.Infrastructure.Iot.Azure.DigitalTwin.RegisterCommandHandlerAsync[T,TX](String commandName, ICommand`2 command, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions