Invalid_frame_end_marker when publishing to RabbitMQ using .net client

I am using the RabbitMQ.net client library to post messages to the RabbitMQ node as follows.

var factory = new ConnectionFactory
                {
                    HostName = "localhost",
                    Port = 5672,
                    UserName = "guest",
                    Password = "guest",
                    VirtualHost = @"/"
                };
_conn = factory.CreateConnection();

_channel = _conn.CreateModel();

_properties = _channel.CreateBasicProperties();

And then below is called in a loop

using (var memStream = new MemoryStream())
{
    var formatter = new BinaryFormatter();

    formatter.Serialize(memStream, message);

    var properties = _channel.CreateBasicProperties();
    properties.Priority = Convert.ToByte((int) priority);

   _channel.BasicPublish(String.Empty, _routeKey, properties, memStream.ToArray());
 }

The above code works fine with an average load of about 50-100 messages per second. But when I increase the number of messages that will be published around 500 messages per second, RabbitMQ node starts to give the error below and disconnects the channel.

Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=501, text="FRAME_ERROR - type 206, first 16 octets = <<31,0,60,0,40,0,0,6,115,101,110,115,111,114,16,115>>:
{invalid_frame_end_marker, 114}
", classId=0, methodId=0, cause=: 
at RabbitMQ.Client.Impl.SessionBase.Transmit(Command cmd) 
at RabbitMQ.Client.Impl.ModelBase.ModelSend(MethodBase method, ContentHeaderBase header, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, Boolean mandatory, Boolean immediate, IBasicProperties basicProperties, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, Boolean mandatory, IBasicProperties basicProperties, Byte[] body) 
at RabbitMQ.Client.Impl.ModelBase.BasicPublish(String exchange, String routingKey, IBasicProperties basicProperties, Byte[] body)`

The size of the message with BinaryFormatter is about 5kb.

+4
source share

Source: https://habr.com/ru/post/1598087/


All Articles