Skip to content

Commit 0b34430

Browse files
committed
Enforce max message size with mutiple content frames
Fixes #1356 * Fix `TestProperties` test so that expected / actual are correct args. * Fix passing MaxInboundMessageBodySize via connection config
1 parent bf9a35a commit 0b34430

15 files changed

+117
-80
lines changed

projects/RabbitMQ.Client/PublicAPI.Unshipped.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const RabbitMQ.Client.AmqpTcpEndpoint.DefaultAmqpSslPort = 5671 -> int
33
const RabbitMQ.Client.AmqpTcpEndpoint.UseDefaultPort = -1 -> int
44
const RabbitMQ.Client.ConnectionFactory.DefaultChannelMax = 2047 -> ushort
55
const RabbitMQ.Client.ConnectionFactory.DefaultFrameMax = 0 -> uint
6-
const RabbitMQ.Client.ConnectionFactory.DefaultMaxMessageSize = 134217728 -> uint
6+
const RabbitMQ.Client.ConnectionFactory.DefaultMaxInboundMessageBodySize = 67108864 -> uint
77
const RabbitMQ.Client.ConnectionFactory.DefaultPass = "guest" -> string
8+
const RabbitMQ.Client.ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize = 134217728 -> uint
89
const RabbitMQ.Client.ConnectionFactory.DefaultUser = "guest" -> string
910
const RabbitMQ.Client.ConnectionFactory.DefaultVHost = "/" -> string
10-
const RabbitMQ.Client.ConnectionFactory.MaximumMaxMessageSize = 536870912 -> uint
1111
const RabbitMQ.Client.Constants.AccessRefused = 403 -> int
1212
const RabbitMQ.Client.Constants.ChannelError = 504 -> int
1313
const RabbitMQ.Client.Constants.CommandInvalid = 503 -> int
@@ -82,14 +82,13 @@ RabbitMQ.Client.AmqpTcpEndpoint.AddressFamily.set -> void
8282
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint() -> void
8383
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne = -1) -> void
8484
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl) -> void
85-
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint maxMessageSize) -> void
8685
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(System.Uri uri) -> void
8786
RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(System.Uri uri, RabbitMQ.Client.SslOption ssl) -> void
8887
RabbitMQ.Client.AmqpTcpEndpoint.Clone() -> object
8988
RabbitMQ.Client.AmqpTcpEndpoint.CloneWithHostname(string hostname) -> RabbitMQ.Client.AmqpTcpEndpoint
9089
RabbitMQ.Client.AmqpTcpEndpoint.HostName.get -> string
9190
RabbitMQ.Client.AmqpTcpEndpoint.HostName.set -> void
92-
RabbitMQ.Client.AmqpTcpEndpoint.MaxMessageSize.get -> uint
91+
RabbitMQ.Client.AmqpTcpEndpoint.MaxInboundMessageBodySize.get -> uint
9392
RabbitMQ.Client.AmqpTcpEndpoint.Port.get -> int
9493
RabbitMQ.Client.AmqpTcpEndpoint.Port.set -> void
9594
RabbitMQ.Client.AmqpTcpEndpoint.Protocol.get -> RabbitMQ.Client.IProtocol
@@ -225,8 +224,8 @@ RabbitMQ.Client.ConnectionFactory.HandshakeContinuationTimeout.get -> System.Tim
225224
RabbitMQ.Client.ConnectionFactory.HandshakeContinuationTimeout.set -> void
226225
RabbitMQ.Client.ConnectionFactory.HostName.get -> string
227226
RabbitMQ.Client.ConnectionFactory.HostName.set -> void
228-
RabbitMQ.Client.ConnectionFactory.MaxMessageSize.get -> uint
229-
RabbitMQ.Client.ConnectionFactory.MaxMessageSize.set -> void
227+
RabbitMQ.Client.ConnectionFactory.MaxInboundMessageBodySize.get -> uint
228+
RabbitMQ.Client.ConnectionFactory.MaxInboundMessageBodySize.set -> void
230229
RabbitMQ.Client.ConnectionFactory.NetworkRecoveryInterval.get -> System.TimeSpan
231230
RabbitMQ.Client.ConnectionFactory.NetworkRecoveryInterval.set -> void
232231
RabbitMQ.Client.ConnectionFactory.Password.get -> string
@@ -787,6 +786,7 @@ readonly RabbitMQ.Client.ConnectionConfig.HandshakeContinuationTimeout -> System
787786
readonly RabbitMQ.Client.ConnectionConfig.HeartbeatInterval -> System.TimeSpan
788787
readonly RabbitMQ.Client.ConnectionConfig.MaxChannelCount -> ushort
789788
readonly RabbitMQ.Client.ConnectionConfig.MaxFrameSize -> uint
789+
readonly RabbitMQ.Client.ConnectionConfig.MaxInboundMessageBodySize -> uint
790790
readonly RabbitMQ.Client.ConnectionConfig.NetworkRecoveryInterval -> System.TimeSpan
791791
readonly RabbitMQ.Client.ConnectionConfig.Password -> string
792792
readonly RabbitMQ.Client.ConnectionConfig.RequestedConnectionTimeout -> System.TimeSpan
@@ -884,6 +884,7 @@ virtual RabbitMQ.Client.TcpClientAdapter.ReceiveTimeout.set -> void
884884
~const RabbitMQ.Client.RabbitMQActivitySource.PublisherSourceName = "RabbitMQ.Client.Publisher" -> string
885885
~const RabbitMQ.Client.RabbitMQActivitySource.SubscriberSourceName = "RabbitMQ.Client.Subscriber" -> string
886886
~override RabbitMQ.Client.Events.EventingBasicConsumer.HandleBasicDeliverAsync(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, RabbitMQ.Client.ReadOnlyBasicProperties properties, System.ReadOnlyMemory<byte> body) -> System.Threading.Tasks.Task
887+
~RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint rabbitMqMaxMessageSize) -> void
887888
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(RabbitMQ.Client.IEndpointResolver endpointResolver, string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
888889
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
889890
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(System.Collections.Generic.IEnumerable<RabbitMQ.Client.AmqpTcpEndpoint> endpoints, string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>

projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,24 @@ public class AmqpTcpEndpoint
6262

6363
private int _port;
6464

65-
private readonly uint _maxMessageSize;
65+
private readonly uint _maxInboundMessageBodySize;
6666

6767
/// <summary>
6868
/// Creates a new instance of the <see cref="AmqpTcpEndpoint"/>.
6969
/// </summary>
7070
/// <param name="hostName">Hostname.</param>
7171
/// <param name="portOrMinusOne"> Port number. If the port number is -1, the default port number will be used.</param>
7272
/// <param name="ssl">Ssl option.</param>
73-
/// <param name="maxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaximumMaxMessageSize"/>. It defaults to
73+
/// <param name="rabbitMqMaxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaxInboundMessageBodySize"/>. It defaults to
7474
/// MaximumMaxMessageSize if the parameter is greater than MaximumMaxMessageSize.</param>
75-
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl, uint maxMessageSize)
75+
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl,
76+
uint rabbitMqMaxMessageSize)
7677
{
7778
HostName = hostName;
7879
_port = portOrMinusOne;
7980
Ssl = ssl;
80-
_maxMessageSize = Math.Min(maxMessageSize, ConnectionFactory.MaximumMaxMessageSize);
81+
_maxInboundMessageBodySize = Math.Min(rabbitMqMaxMessageSize,
82+
ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize);
8183
}
8284

8385
/// <summary>
@@ -87,7 +89,7 @@ public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl, uint
8789
/// <param name="portOrMinusOne"> Port number. If the port number is -1, the default port number will be used.</param>
8890
/// <param name="ssl">Ssl option.</param>
8991
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl) :
90-
this(hostName, portOrMinusOne, ssl, ConnectionFactory.DefaultMaxMessageSize)
92+
this(hostName, portOrMinusOne, ssl, ConnectionFactory.DefaultMaxInboundMessageBodySize)
9193
{
9294
}
9395

@@ -134,7 +136,7 @@ public AmqpTcpEndpoint(Uri uri) : this(uri.Host, uri.Port)
134136
/// <returns>A copy with the same hostname, port, and TLS settings</returns>
135137
public object Clone()
136138
{
137-
return new AmqpTcpEndpoint(HostName, _port, Ssl, _maxMessageSize);
139+
return new AmqpTcpEndpoint(HostName, _port, Ssl, _maxInboundMessageBodySize);
138140
}
139141

140142
/// <summary>
@@ -144,7 +146,7 @@ public object Clone()
144146
/// <returns>A copy with the provided hostname and port/TLS settings of this endpoint</returns>
145147
public AmqpTcpEndpoint CloneWithHostname(string hostname)
146148
{
147-
return new AmqpTcpEndpoint(hostname, _port, Ssl, _maxMessageSize);
149+
return new AmqpTcpEndpoint(hostname, _port, Ssl, _maxInboundMessageBodySize);
148150
}
149151

150152
/// <summary>
@@ -195,11 +197,11 @@ public IProtocol Protocol
195197

196198
/// <summary>
197199
/// Get the maximum size for a message in bytes.
198-
/// The default value is defined in <see cref="ConnectionFactory.DefaultMaxMessageSize"/>.
200+
/// The default value is defined in <see cref="ConnectionFactory.DefaultMaxInboundMessageBodySize"/>.
199201
/// </summary>
200-
public uint MaxMessageSize
202+
public uint MaxInboundMessageBodySize
201203
{
202-
get { return _maxMessageSize; }
204+
get { return _maxInboundMessageBodySize; }
203205
}
204206

205207
/// <summary>

projects/RabbitMQ.Client/client/api/ConnectionConfig.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public sealed class ConnectionConfig
9090
/// </summary>
9191
public readonly uint MaxFrameSize;
9292

93+
/// <summary>
94+
/// Maximum body size of a message (in bytes).
95+
/// </summary>
96+
public readonly uint MaxInboundMessageBodySize;
97+
9398
/// <summary>
9499
/// Set to false to make automatic connection recovery not recover topology (exchanges, queues, bindings, etc).
95100
/// </summary>
@@ -149,7 +154,7 @@ internal ConnectionConfig(string virtualHost, string userName, string password,
149154
ICredentialsProvider credentialsProvider, ICredentialsRefresher credentialsRefresher,
150155
IEnumerable<IAuthMechanismFactory> authMechanisms,
151156
IDictionary<string, object?> clientProperties, string? clientProvidedName,
152-
ushort maxChannelCount, uint maxFrameSize, bool topologyRecoveryEnabled,
157+
ushort maxChannelCount, uint maxFrameSize, uint maxInboundMessageBodySize, bool topologyRecoveryEnabled,
153158
TopologyRecoveryFilter topologyRecoveryFilter, TopologyRecoveryExceptionHandler topologyRecoveryExceptionHandler,
154159
TimeSpan networkRecoveryInterval, TimeSpan heartbeatInterval, TimeSpan continuationTimeout, TimeSpan handshakeContinuationTimeout, TimeSpan requestedConnectionTimeout,
155160
bool dispatchConsumersAsync, int dispatchConsumerConcurrency,
@@ -165,6 +170,7 @@ internal ConnectionConfig(string virtualHost, string userName, string password,
165170
ClientProvidedName = clientProvidedName;
166171
MaxChannelCount = maxChannelCount;
167172
MaxFrameSize = maxFrameSize;
173+
MaxInboundMessageBodySize = maxInboundMessageBodySize;
168174
TopologyRecoveryEnabled = topologyRecoveryEnabled;
169175
TopologyRecoveryFilter = topologyRecoveryFilter;
170176
TopologyRecoveryExceptionHandler = topologyRecoveryExceptionHandler;

projects/RabbitMQ.Client/client/api/ConnectionFactory.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace RabbitMQ.Client
5959
/// factory.VirtualHost = ConnectionFactory.DefaultVHost;
6060
/// factory.HostName = hostName;
6161
/// factory.Port = AmqpTcpEndpoint.UseDefaultPort;
62-
/// factory.MaxMessageSize = 512 * 1024 * 1024;
62+
/// factory.MaxInboundMessageBodySize = 512 * 1024 * 1024;
6363
/// //
6464
/// IConnection conn = factory.CreateConnection();
6565
/// //
@@ -107,15 +107,16 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactor
107107
public const uint DefaultFrameMax = 0;
108108

109109
/// <summary>
110-
/// Default value for <code>ConnectionFactory</code>'s <code>MaxMessageSize</code>.
110+
/// Default value for <code>ConnectionFactory</code>'s <code>MaxInboundMessageBodySize</code>.
111111
/// </summary>
112-
public const uint DefaultMaxMessageSize = 134217728;
112+
public const uint DefaultMaxInboundMessageBodySize = 1_048_576 * 64;
113+
113114
/// <summary>
114115
/// Largest message size, in bytes, allowed in RabbitMQ.
115116
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
116-
/// configures the largest message size which should be lower than this maximum of 536 Mbs.
117+
/// configures the largest message size which should be lower than this maximum of 128MiB.
117118
/// </summary>
118-
public const uint MaximumMaxMessageSize = 536870912;
119+
public const uint DefaultRabbitMqMaxInboundMessageBodySize = 1_048_576 * 128;
119120

120121
/// <summary>
121122
/// Default value for desired heartbeat interval. Default is 60 seconds,
@@ -291,13 +292,13 @@ public ConnectionFactory()
291292
/// </summary>
292293
public AmqpTcpEndpoint Endpoint
293294
{
294-
get { return new AmqpTcpEndpoint(HostName, Port, Ssl, MaxMessageSize); }
295+
get { return new AmqpTcpEndpoint(HostName, Port, Ssl, MaxInboundMessageBodySize); }
295296
set
296297
{
297298
Port = value.Port;
298299
HostName = value.HostName;
299300
Ssl = value.Ssl;
300-
MaxMessageSize = value.MaxMessageSize;
301+
MaxInboundMessageBodySize = value.MaxInboundMessageBodySize;
301302
}
302303
}
303304

@@ -359,7 +360,7 @@ public AmqpTcpEndpoint Endpoint
359360
/// Maximum allowed message size, in bytes, from RabbitMQ.
360361
/// Corresponds to the <code>ConnectionFactory.DefaultMaxMessageSize</code> setting.
361362
/// </summary>
362-
public uint MaxMessageSize { get; set; } = DefaultMaxMessageSize;
363+
public uint MaxInboundMessageBodySize { get; set; } = DefaultMaxInboundMessageBodySize;
363364

364365
/// <summary>
365366
/// The uri to use for the connection.
@@ -484,7 +485,7 @@ public Task<IConnection> CreateConnectionAsync(IEnumerable<string> hostnames,
484485
public Task<IConnection> CreateConnectionAsync(IEnumerable<string> hostnames, string clientProvidedName,
485486
CancellationToken cancellationToken = default)
486487
{
487-
IEnumerable<AmqpTcpEndpoint> endpoints = hostnames.Select(h => new AmqpTcpEndpoint(h, Port, Ssl, MaxMessageSize));
488+
IEnumerable<AmqpTcpEndpoint> endpoints = hostnames.Select(h => new AmqpTcpEndpoint(h, Port, Ssl, MaxInboundMessageBodySize));
488489
return CreateConnectionAsync(EndpointResolverFactory(endpoints), clientProvidedName, cancellationToken);
489490
}
490491

@@ -602,6 +603,7 @@ private ConnectionConfig CreateConfig(string clientProvidedName)
602603
clientProvidedName,
603604
RequestedChannelMax,
604605
RequestedFrameMax,
606+
MaxInboundMessageBodySize,
605607
TopologyRecoveryEnabled,
606608
TopologyRecoveryFilter,
607609
TopologyRecoveryExceptionHandler,

projects/RabbitMQ.Client/client/impl/CommandAssembler.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ internal sealed class CommandAssembler
5555
private int _offset;
5656
private AssemblyState _state;
5757

58-
public CommandAssembler()
58+
private readonly uint _maxBodyLength;
59+
60+
public CommandAssembler(uint maxBodyLength)
5961
{
62+
_maxBodyLength = maxBodyLength;
6063
Reset();
6164
}
6265

@@ -148,10 +151,17 @@ private bool ParseHeaderFrame(in InboundFrame frame)
148151
}
149152

150153
ulong totalBodyBytes = NetworkOrderDeserializer.ReadUInt64(span.Slice(4));
151-
if (totalBodyBytes > MaxArrayOfBytesSize)
154+
if (totalBodyBytes >= MaxArrayOfBytesSize)
152155
{
153156
throw new UnexpectedFrameException(frame.Type);
154157
}
158+
159+
if (totalBodyBytes >= _maxBodyLength)
160+
{
161+
string msg = $"Frame body size '{totalBodyBytes}' exceeds maximum of '{_maxBodyLength}' bytes";
162+
throw new MalformedFrameException(message: msg, canShutdownCleanly: false);
163+
}
164+
155165
_rentedHeaderArray = totalBodyBytes != 0 ? frame.TakeoverPayload() : Array.Empty<byte>();
156166

157167
_headerMemory = frame.Payload.Slice(12);

projects/RabbitMQ.Client/client/impl/Connection.Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ await FinishCloseAsync(cancellationToken)
171171
}
172172

173173
ushort channelMax = (ushort)NegotiatedMaxValue(_config.MaxChannelCount, connectionTune.m_channelMax);
174-
_sessionManager = new SessionManager(this, channelMax);
174+
_sessionManager = new SessionManager(this, channelMax, _config.MaxInboundMessageBodySize);
175175

176176
uint frameMax = NegotiatedMaxValue(_config.MaxFrameSize, connectionTune.m_frameMax);
177177
FrameMax = frameMax;

projects/RabbitMQ.Client/client/impl/Connection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ internal Connection(ConnectionConfig config, IFrameHandler frameHandler)
7171
_connectionUnblockedWrapper = new EventingWrapper<EventArgs>("OnConnectionUnblocked", onException);
7272
_connectionShutdownWrapper = new EventingWrapper<ShutdownEventArgs>("OnShutdown", onException);
7373

74-
_sessionManager = new SessionManager(this, 0);
75-
_session0 = new MainSession(this);
74+
_sessionManager = new SessionManager(this, 0, config.MaxInboundMessageBodySize);
75+
_session0 = new MainSession(this, config.MaxInboundMessageBodySize);
7676
_channel0 = new Channel(_config, _session0); ;
7777

7878
ClientProperties = new Dictionary<string, object?>(_config.ClientProperties)

projects/RabbitMQ.Client/client/impl/Frame.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ private static void ProcessProtocolHeader(ReadOnlySequence<byte> buffer)
254254
}
255255
}
256256

257-
internal static async ValueTask<InboundFrame> ReadFromPipeAsync(PipeReader reader, uint maxMessageSize,
257+
internal static async ValueTask<InboundFrame> ReadFromPipeAsync(PipeReader reader,
258+
uint maxInboundMessageBodySize,
258259
CancellationToken mainLoopCancellationToken)
259260
{
260261
ReadResult result = await reader.ReadAsync(mainLoopCancellationToken)
@@ -266,7 +267,7 @@ internal static async ValueTask<InboundFrame> ReadFromPipeAsync(PipeReader reade
266267

267268
InboundFrame frame;
268269
// Loop until we have enough data to read an entire frame, or until the pipe is completed.
269-
while (!TryReadFrame(ref buffer, maxMessageSize, out frame))
270+
while (!TryReadFrame(ref buffer, maxInboundMessageBodySize, out frame))
270271
{
271272
reader.AdvanceTo(buffer.Start, buffer.End);
272273

@@ -283,15 +284,16 @@ internal static async ValueTask<InboundFrame> ReadFromPipeAsync(PipeReader reade
283284
return frame;
284285
}
285286

286-
internal static bool TryReadFrameFromPipe(PipeReader reader, uint maxMessageSize, out InboundFrame frame)
287+
internal static bool TryReadFrameFromPipe(PipeReader reader,
288+
uint maxInboundMessageBodySize, out InboundFrame frame)
287289
{
288290
if (reader.TryRead(out ReadResult result))
289291
{
290292
ReadOnlySequence<byte> buffer = result.Buffer;
291293

292294
MaybeThrowEndOfStream(result, buffer);
293295

294-
if (TryReadFrame(ref buffer, maxMessageSize, out frame))
296+
if (TryReadFrame(ref buffer, maxInboundMessageBodySize, out frame))
295297
{
296298
reader.AdvanceTo(buffer.Start);
297299
return true;
@@ -306,7 +308,8 @@ internal static bool TryReadFrameFromPipe(PipeReader reader, uint maxMessageSize
306308
return false;
307309
}
308310

309-
internal static bool TryReadFrame(ref ReadOnlySequence<byte> buffer, uint maxMessageSize, out InboundFrame frame)
311+
internal static bool TryReadFrame(ref ReadOnlySequence<byte> buffer,
312+
uint maxInboundMessageBodySize, out InboundFrame frame)
310313
{
311314
if (buffer.Length < 7)
312315
{
@@ -332,9 +335,9 @@ internal static bool TryReadFrame(ref ReadOnlySequence<byte> buffer, uint maxMes
332335
FrameType type = (FrameType)firstByte;
333336
int channel = NetworkOrderDeserializer.ReadUInt16(buffer.Slice(1));
334337
int payloadSize = NetworkOrderDeserializer.ReadInt32(buffer.Slice(3));
335-
if ((maxMessageSize > 0) && (payloadSize > maxMessageSize))
338+
if ((maxInboundMessageBodySize > 0) && (payloadSize > maxInboundMessageBodySize))
336339
{
337-
string msg = $"Frame payload size '{payloadSize}' exceeds maximum of '{maxMessageSize}' bytes";
340+
string msg = $"Frame payload size '{payloadSize}' exceeds maximum of '{maxInboundMessageBodySize}' bytes";
338341
throw new MalformedFrameException(message: msg, canShutdownCleanly: false);
339342
}
340343

0 commit comments

Comments
 (0)