title: How do I adjust the maximum message size for a BrokeredMessage in Windows Server Service Bus?
body: <p>I've set up Windows Server Service Bus 1.0 on a VM running Windows Server 2008 R2 Datacenter.</p>
  
  <p>I've written a console application to send and receive messages to and from it and this works well.</p>
  
  <p>I've been sending messages of increasing size successfully but the console app currently falls over when getting to 5,226,338 bytes (5,226,154 bytes message body + 184 bytes header I believe) which is just under 5MB.  Ideally we need a bit more room to play with.</p>
  
  <p>Some of the stack trace is as below...</p>
  
  <blockquote>
    <p>Unhandled Exception:
    Microsoft.ServiceBus.Messaging.MessagingCommunicationException: The
    socket connection was aborted. This could be caused by an error
    processing your message or a receive timeout being exceeded by the
    remote host, or an underlying network resource issue. Local socket
    timeout was '00:01:09.2720000'. - -->
    System.ServiceModel.CommunicationException: The socket connection was
    aborted. This could be caused by an error processing your message or a
    receive timeout being exceeded by the remote host, or an underlying
    network resource issue. Local socket timeout was '00:01:09.2720000'.
    ---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket
    connection was aborted. This could be caused by an error processing
    your message or a receive timeout being exceeded by the remote host,
    or an underlying network resource issue. Local socket timeout was
    '00:01:09.2720000' . ---> System.Net.Sockets.SocketException: An
    established connection was aborted by the software in your host
    machine</p>
  </blockquote>
  
  <p>The Windows Azure Service Bus apparently has a fixed limit of 256KB but the on premise Windows Server Service Bus has a limit of 50MB.  See the articles below.</p>
  
  <p>Mention of the Azure limit of 256KB - <a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh694235.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windowsazure/hh694235.aspx</a></p>
  
  <p>Mention of 50MB - <a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj193026.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windowsazure/jj193026.aspx</a></p>
  
  <p>I'm struggling to achieve the 50MB limit and would like to know if there is something I need to do to configure this somehow or perhaps the message needs to be sent in a certain way.  I noticed there was a parameter name in the above article and wondered if that could be used in PowerShell.</p>
  
  <p>I've struggled to find some good information on this online.  There is much confusion out there with some articles relating to Azure Service Bus but others relating to Windows Server Service Bus.</p>
  
  <p>There is Service Bus 1.1 but I think this is in preview at the moment and I'm not sure this will help.</p>
  
  <p>I am using code similar to the below to send the message.</p>
  
  <p>namespaceManager = NamespaceManager.Create();
  messagingFactory = MessagingFactory.Create();</p>
  
  <p>queueClient = messagingFactory.CreateQueueClient(queueName);</p>
  
  <p>queueClient.Send(new BrokeredMessage(new string('x', 5226154)));</p>
  
  <p>This was taken from a combination of the articles below, the first one being slightly outdated and second one making it slightly clearer what needed to be changed in order to get things working.</p>
  
  <p><a href="http://haishibai.blogspot.co.uk/2012/08/walkthrough-setting-up-development.html" rel="nofollow">http://haishibai.blogspot.co.uk/2012/08/walkthrough-setting-up-development.html</a></p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj218335(v=azure.10).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windowsazure/jj218335(v=azure.10).aspx</a></p>
  
  <p>I hope someone can help.</p>