When opening a new connection to an AMQP peer using the Open class and the ConnectionFactory class, there is a property called MaxFrameSize on the Open class. If you set this and then pass it along to the to the ConnectionFactory's CreateAsync method, the value is overridden by the value on the AMQP instance member of the ConnectionFactory.
var openParameters = new Open
{
ContainerId = clientId,
MaxFrameSize = 1024 * 1024 // override default of 256kb to 1mb
};
var address = new Address(
host,
connectionOptions.Port,
connectionOptions.Username,
connectionOptions.Password);
var connectionFactory = new ConnectionFactory();
IConnection connection= await connectionFactory.CreateAsync(address, open, onOpened);
/*
At this point, I'd expect to be able to send AND receive a message that's roughly 1mb in size (maybe a little smaller because of AMQP headers and other format-y stuff). It looks like the sending portion works correctly, but the receiving portion raises an exception.
*/
ISession session = connection.CreateSession();
ISenderLink senderLink = session.CreateSender($"{senderOptions.DestinationName}-link", senderOptions.DestinationName);
var message = new Message(new string('a', 500000));
await senderLink .SendAsync(message, senderOptions.PublicationTimeout);
var receiverLink = session.CreateReceiver($"{sourceName}-link", sourceName);
var message = receiverLink.ReceiveAsync(timeout);
This raises the following exception
Amqp.AmqpException: Invalid frame size:500281, maximum frame size:262144.
To workaround this issue, you can set the MaxFrameSize directly on the AMQP instance member and the behavior is as expected, but it's confusing without looking directly at source code.
var connectionFactory = new ConnectionFactory();
connectionFactory.AMQP.MaxFrameSize = 1024 * 1024;
And all of sudden, there's no exception and the message is picked up.
When opening a new connection to an AMQP peer using the Open class and the ConnectionFactory class, there is a property called
MaxFrameSize
on the Open class. If you set this and then pass it along to the to the ConnectionFactory's CreateAsync method, the value is overridden by the value on the AMQP instance member of the ConnectionFactory.This raises the following exception
To workaround this issue, you can set the MaxFrameSize directly on the AMQP instance member and the behavior is as expected, but it's confusing without looking directly at source code.
And all of sudden, there's no exception and the message is picked up.