Skip to content

Commit 9600809

Browse files
committed
Finish forward-porting #1224 to main
1 parent 2f28a0f commit 9600809

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl, uint
8686
/// <param name="portOrMinusOne"> Port number. If the port number is -1, the default port number will be used.</param>
8787
/// <param name="ssl">Ssl option.</param>
8888
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl) :
89-
this(hostName, portOrMinusOne, ssl, 0)
89+
this(hostName, portOrMinusOne, ssl, ConnectionFactory.DefaultMaxMessageSize)
9090
{
9191
}
9292

@@ -193,7 +193,7 @@ public IProtocol Protocol
193193
public SslOption Ssl { get; set; }
194194

195195
/// <summary>
196-
/// Get the maximum size for a message in bytes. The default value is 0 (unlimited)
196+
/// Get the maximum size for a message in bytes. The default value is 128MiB to match RabbitMQ's default
197197
/// </summary>
198198
public uint MaxMessageSize
199199
{

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ private void HardProtocolExceptionHandler(HardProtocolException hpe)
149149
{
150150
var cmd = new ConnectionClose(hpe.ShutdownReason.ReplyCode, hpe.ShutdownReason.ReplyText, 0, 0);
151151
_session0.Transmit(ref cmd);
152-
ClosingLoop();
152+
if (hpe.CanShutdownCleanly)
153+
{
154+
ClosingLoop();
155+
}
153156
}
154157
catch (IOException ioe)
155158
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ internal static InboundFrame ReadFrom(Stream reader, byte[] frameHeaderBuffer, u
278278
var frameHeaderSpan = new ReadOnlySpan<byte>(frameHeaderBuffer, 1, 6);
279279
int channel = NetworkOrderDeserializer.ReadUInt16(frameHeaderSpan);
280280
int payloadSize = NetworkOrderDeserializer.ReadInt32(frameHeaderSpan.Slice(2, 4));
281-
if (payloadSize > maxMessageSize)
281+
if ((maxMessageSize > 0) && (payloadSize > maxMessageSize))
282282
{
283283
string msg = $"Frame payload size '{payloadSize}' exceeds maximum of '{maxMessageSize}' bytes";
284284
throw new MalformedFrameException(message: msg, canShutdownCleanly: false);

projects/Unit/APIApproval.Approve.verified.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ namespace RabbitMQ.Client
152152
{
153153
public const ushort DefaultChannelMax = 2047;
154154
public const uint DefaultFrameMax = 0u;
155-
public const uint DefaultMaxMessageSize = 0u;
155+
public const uint DefaultMaxMessageSize = 134217728u;
156156
public const string DefaultPass = "guest";
157157
public const string DefaultUser = "guest";
158158
public const string DefaultVHost = "/";
@@ -211,7 +211,6 @@ namespace RabbitMQ.Client
211211
public const int CommandInvalid = 503;
212212
public const int ConnectionForced = 320;
213213
public const int ContentTooLarge = 311;
214-
public const uint DefaultMaxMessageSizeInBytes = 134217728u;
215214
public const int FrameBody = 3;
216215
public const int FrameEnd = 206;
217216
public const int FrameError = 501;
@@ -945,4 +944,4 @@ namespace RabbitMQ.Client.Logging
945944
public string Type { get; }
946945
public override string ToString() { }
947946
}
948-
}
947+
}

0 commit comments

Comments
 (0)