Q:

How do I adjust the maximum message size for a BrokeredMessage in Windows Server Service Bus?

I've set up Windows Server Service Bus 1.0 on a VM running Windows Server 2008 R2 Datacenter.
I've written a console application to send and receive messages to and from it and this works well.
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.
Some of the stack trace is as below...

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

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.
Mention of the Azure limit of 256KB - http://msdn.microsoft.com/en-us/library/windowsazure/hh694235.aspx
Mention of 50MB - http://msdn.microsoft.com/en-us/library/windowsazure/jj193026.aspx
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.
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.
There is Service Bus 1.1 but I think this is in preview at the moment and I'm not sure this will help.
I am using code similar to the below to send the message.
namespaceManager = NamespaceManager.Create();
messagingFactory = MessagingFactory.Create();
queueClient = messagingFactory.CreateQueueClient(queueName);
queueClient.Send(new BrokeredMessage(new string('x', 5226154)));
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.
http://haishibai.blogspot.co.uk/2012/08/walkthrough-setting-up-development.html
http://msdn.microsoft.com/en-us/library/windowsazure/jj218335(v=azure.10).aspx
I hope someone can help.

A:

I've had the same problem but I have figured it out after few tries.
Just open file
C:\Program Files\Service Bus\1.1\Microsoft.ServiceBus.Gateway.exe.config

and change nettcp binding with name netMessagingProtocolHead set 
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"

and restart all service bus services.
Now I'am able to send and receive message with size new string('A', 49 * 1024 * 1024).
Enjoy :-)
Martin

