mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 04:03:05 +08:00
Expose configuration of packet fragmentation in server options. (#1769)
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
* [Client] Fixed _PlatformNotSupportedException_ when using Blazor (#1755, thanks to @Nickztar).
|
* [Client] Fixed _PlatformNotSupportedException_ when using Blazor (#1755, thanks to @Nickztar).
|
||||||
* [Server] Fixed _NullReferenceException_ in retained messages management (#1762, thanks to @logicaloud).
|
* [Server] Fixed _NullReferenceException_ in retained messages management (#1762, thanks to @logicaloud).
|
||||||
|
* [Server] Exposed new option which allows disabling packet fragmentation (#1753).
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ namespace MQTTnet.Implementations
|
|||||||
|
|
||||||
using (var clientAdapter = new MqttChannelAdapter(tcpChannel, packetFormatterAdapter, _rootLogger))
|
using (var clientAdapter = new MqttChannelAdapter(tcpChannel, packetFormatterAdapter, _rootLogger))
|
||||||
{
|
{
|
||||||
|
clientAdapter.AllowPacketFragmentation = _options.AllowPacketFragmentation;
|
||||||
await clientHandler(clientAdapter).ConfigureAwait(false);
|
await clientHandler(clientAdapter).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +256,7 @@ namespace MQTTnet.Implementations
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// ReSharper disable once MethodHasAsyncOverload
|
||||||
stream?.Dispose();
|
stream?.Dispose();
|
||||||
clientSocket?.Dispose();
|
clientSocket?.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,18 @@ namespace MQTTnet.Server
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Usually the MQTT packets can be send partially to improve memory allocations.
|
||||||
|
/// This is done by using multiple TCP packets or WebSocket frames etc.
|
||||||
|
/// Unfortunately not all clients do support this and will close the connection when receiving partial packets.
|
||||||
|
/// </summary>
|
||||||
|
public MqttServerOptionsBuilder WithoutPacketFragmentation()
|
||||||
|
{
|
||||||
|
_options.DefaultEndpointOptions.AllowPacketFragmentation = false;
|
||||||
|
_options.TlsEndpointOptions.AllowPacketFragmentation = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MqttServerOptionsBuilder WithPersistentSessions(bool value = true)
|
public MqttServerOptionsBuilder WithPersistentSessions(bool value = true)
|
||||||
{
|
{
|
||||||
_options.EnablePersistentSessions = value;
|
_options.EnablePersistentSessions = value;
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ namespace MQTTnet.Server
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? KeepAlive { get; set; }
|
public bool? KeepAlive { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Usually the MQTT packets can be send partially. This is done by using multiple TCP packets
|
||||||
|
/// or WebSocket frames etc. Unfortunately not all clients do support this feature and
|
||||||
|
/// will close the connection when receiving such packets. If such clients are connecting to this
|
||||||
|
/// server the flag must be set to _false_.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowPacketFragmentation { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the TCP keep alive interval.
|
/// Gets or sets the TCP keep alive interval.
|
||||||
/// The value _null_ indicates that the OS and framework defaults should be used.
|
/// The value _null_ indicates that the OS and framework defaults should be used.
|
||||||
|
|||||||
Reference in New Issue
Block a user