Service Bus Issue while sending Large messages to a queue

I recently got a case where my customer was trying to send large messages (> 5 MB) to a service bus queue and was getting a below error message. Smaller messages (< 5 MB) would go through without any issue. 

Error:

Microsoft.ServiceBus.Messaging.MessagingCommunicationException was unhandled
HResult=-2146233088
Message=Error during communication with Service Bus. Check the connection information, then retry.
Source=Microsoft.ServiceBus
IsTransient=true
StackTrace:
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)

at
Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at
Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage message)

at
Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage message)

at
CSG.ServiceBus.Client.GeneralQueueClient`1.Send(T value)

at
CSG.ServiceBus.ServiceBusProvider.ServiceBusQueue`1.Enqueue(T message)

at
QueueSizing.Program.Main(String[] args) in C:\usr\Development\Mobility\ProofOfConcept\QueueSizing\QueueSizing\Program.cs:line 51

at
System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at
System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at
System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ServiceModel.CommunicationObjectFaultedException HResult=-2146233087
Message=Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown..TrackingId:18787480-6512-4c57-89ea-2618291dd1fb, Timestamp:9/24/2013 2:16:48 PM
Source=Microsoft.ServiceBus
StackTrace:
Server stack trace:
Exception rethrown at [0]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)

at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [1]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

at
Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass17.<GetAsyncSteps>b__a(RequestAsyncResult thisPtr, IAsyncResult r)

at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [2]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at
Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

at
Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)

at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [3]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

at
Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)

at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<GetAsyncSteps>b__36(TIteratorAsyncResult thisPtr, IAsyncResult a)

at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [4]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

at
Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)

I tried to reproduce the issue on my machine and I too faced the similar issue while sending larger messages. I found the resolution after a bit of research/troubleshooting at my end.

It seems that there is a configuration value in the “Microsoft.ServiceBus.Gateway.exe.config” file (located at “C:\Program Files\Service Bus\1.0”) which is restricting the larger messages to be received in the service bus queue.

<binding name="netMessagingProtocolHead" receiveTimeout="24:00:00" listenBacklog="64" maxConnections="64" maxReceivedMessageSize="5242880" maxBufferSize="5242880">
          <readerQuotas maxArrayLength="5242880" maxDepth="64" maxStringContentLength="5242880" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security> 
            <transport clientCredentialType="None"></transport> 
          </security>
        </binding>

The value “maxReceivedMessageSize”, by default, is set to 5MB and hence we were not able to send the larger messages. I tried to increase this value to a larger value (close to 8MB) and I was able to send a 6MB message without any issues.

I hope this helps.

 

Written By
Yakshit Gohel

Reviewed By
Jainath V R

Microsoft GTSC India