Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Source/MQTTnet/Implementations/MqttTcpChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public async Task ConnectAsync(CancellationToken cancellationToken)
socket.Bind(_tcpOptions.LocalEndpoint);
}

socket.ReceiveBufferSize = _tcpOptions.BufferSize;
socket.SendBufferSize = _tcpOptions.BufferSize;
if (_tcpOptions.BufferSize > 0)
{
socket.ReceiveBufferSize = _tcpOptions.BufferSize;
socket.SendBufferSize = _tcpOptions.BufferSize;
}
socket.SendTimeout = (int)_clientOptions.Timeout.TotalMilliseconds;

if (_tcpOptions.ProtocolType == ProtocolType.Tcp)
Expand Down
8 changes: 7 additions & 1 deletion Source/MQTTnet/Options/MqttClientTcpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ public sealed class MqttClientTcpOptions : IMqttClientChannelOptions
{
public AddressFamily AddressFamily { get; set; } = AddressFamily.Unspecified;

public int BufferSize { get; set; } = 8192;
/// <summary>
/// Gets or sets the socket send and receive buffer size in bytes.
/// Values less than or equal to 0 keep the OS defaults (including TCP window auto-tuning).
/// A small fixed value limits throughput for large payloads.
/// Default: 0
/// </summary>
public int BufferSize { get; set; }

/// <summary>
/// Gets or sets whether the underlying socket should run in dual mode.
Expand Down
1 change: 1 addition & 0 deletions Source/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* Client: Add support for SOCKS5 proxies (#2251, thanks to @koepalex)
* Client: Fixed keep alive ping send timeout disconnect handling (#2253, thanks to @suhashollakc)
* Server: Fixed exposing Topic Alias to clients (#2250, thanks to @suhashollakc)
* Client: `MqttClientTcpOptions.BufferSize` now defaults to the OS socket buffer sizes instead of a fixed 8 KB, which throttled large payload throughput (#2234)