diff --git a/Source/MQTTnet.Server/Configuration/SettingsModel.cs b/Source/MQTTnet.Server/Configuration/SettingsModel.cs
index 228ae1dc..713f664e 100644
--- a/Source/MQTTnet.Server/Configuration/SettingsModel.cs
+++ b/Source/MQTTnet.Server/Configuration/SettingsModel.cs
@@ -23,17 +23,17 @@
///
/// Listen Settings
///
- public TcpEndpointModel TcpEndPoint { get; set; } = new TcpEndpointModel();
+ public TcpEndPointModel TcpEndPoint { get; set; } = new TcpEndPointModel();
///
/// Encryption Listen Settings
///
- public TcpEndpointModel EncryptedTcpEndPoint { get; set; } = new TcpEndpointModel();
+ public TcpEndPointModel EncryptedTcpEndPoint { get; set; } = new TcpEndPointModel();
///
/// Settings for the Web Socket endpoint.
///
- public WebSocketEndpointModel WebSocketEndpoint { get; set; } = new WebSocketEndpointModel();
+ public WebSocketEndPointModel WebSocketEndPoint { get; set; } = new WebSocketEndPointModel();
///
/// Set limit for max pending messages per client
diff --git a/Source/MQTTnet.Server/Configuration/TcpEndpointModel.cs b/Source/MQTTnet.Server/Configuration/TcpEndpointModel.cs
index ccec56bb..0f006c27 100644
--- a/Source/MQTTnet.Server/Configuration/TcpEndpointModel.cs
+++ b/Source/MQTTnet.Server/Configuration/TcpEndpointModel.cs
@@ -6,15 +6,8 @@ namespace MQTTnet.Server.Configuration
///
/// Listen Entry Settings Model
///
- public class TcpEndpointModel
+ public class TcpEndPointModel
{
- ///
- /// Constructor
- ///
- public TcpEndpointModel()
- {
- }
-
///
/// Path to Certificate
///
diff --git a/Source/MQTTnet.Server/Configuration/WebSocketEndpointModel.cs b/Source/MQTTnet.Server/Configuration/WebSocketEndpointModel.cs
index 46610792..50a1dae0 100644
--- a/Source/MQTTnet.Server/Configuration/WebSocketEndpointModel.cs
+++ b/Source/MQTTnet.Server/Configuration/WebSocketEndpointModel.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace MQTTnet.Server.Configuration
{
- public class WebSocketEndpointModel
+ public class WebSocketEndPointModel
{
public bool Enabled { get; set; } = true;
diff --git a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs
index f4b7a034..c25108ae 100644
--- a/Source/MQTTnet.Server/Mqtt/MqttServerService.cs
+++ b/Source/MQTTnet.Server/Mqtt/MqttServerService.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
+using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
using IronPython.Runtime;
@@ -146,7 +147,7 @@ namespace MQTTnet.Server.Mqtt
.WithApplicationMessageInterceptor(_mqttApplicationMessageInterceptor)
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor)
.WithStorage(_mqttServerStorage);
-
+
// Configure unencrypted connections
if (_settings.TcpEndPoint.Enabled)
{
@@ -176,7 +177,7 @@ namespace MQTTnet.Server.Mqtt
{
options
.WithEncryptedEndpoint()
- .WithEncryptionSslProtocol(System.Security.Authentication.SslProtocols.Tls12)
+ .WithEncryptionSslProtocol(SslProtocols.Tls12)
.WithEncryptionCertificate(_settings.EncryptedTcpEndPoint.ReadCertificate());
if (_settings.EncryptedTcpEndPoint.TryReadIPv4(out var address4))
@@ -204,6 +205,11 @@ namespace MQTTnet.Server.Mqtt
options.WithConnectionBacklog(_settings.ConnectionBacklog);
}
+ if (_settings.EnablePersistentSessions)
+ {
+ options.WithPersistentSessions();
+ }
+
return options.Build();
}
}
diff --git a/Source/MQTTnet.Server/Startup.cs b/Source/MQTTnet.Server/Startup.cs
index b50e9409..8d9c3ee3 100644
--- a/Source/MQTTnet.Server/Startup.cs
+++ b/Source/MQTTnet.Server/Startup.cs
@@ -93,32 +93,32 @@ namespace MQTTnet.Server
MqttServerService mqttServerService,
SettingsModel settings)
{
- if (settings?.WebSocketEndpoint?.Enabled != true)
+ if (settings?.WebSocketEndPoint?.Enabled != true)
{
return;
}
- if (string.IsNullOrEmpty(settings.WebSocketEndpoint.Path))
+ if (string.IsNullOrEmpty(settings.WebSocketEndPoint.Path))
{
return;
}
var webSocketOptions = new WebSocketOptions
{
- KeepAliveInterval = TimeSpan.FromSeconds(settings.WebSocketEndpoint.KeepAliveInterval),
- ReceiveBufferSize = settings.WebSocketEndpoint.ReceiveBufferSize
+ KeepAliveInterval = TimeSpan.FromSeconds(settings.WebSocketEndPoint.KeepAliveInterval),
+ ReceiveBufferSize = settings.WebSocketEndPoint.ReceiveBufferSize
};
- if (settings.WebSocketEndpoint.AllowedOrigins?.Any() == true)
+ if (settings.WebSocketEndPoint.AllowedOrigins?.Any() == true)
{
- webSocketOptions.AllowedOrigins.AddRange(settings.WebSocketEndpoint.AllowedOrigins);
+ webSocketOptions.AllowedOrigins.AddRange(settings.WebSocketEndPoint.AllowedOrigins);
}
application.UseWebSockets(webSocketOptions);
application.Use(async (context, next) =>
{
- if (context.Request.Path == settings.WebSocketEndpoint.Path)
+ if (context.Request.Path == settings.WebSocketEndPoint.Path)
{
if (context.WebSockets.IsWebSocketRequest)
{
diff --git a/Source/MQTTnet.Server/appsettings.json b/Source/MQTTnet.Server/appsettings.json
index ce93bddc..d3fdf9f3 100644
--- a/Source/MQTTnet.Server/appsettings.json
+++ b/Source/MQTTnet.Server/appsettings.json
@@ -29,7 +29,7 @@
"Port": 8883,
"CertificatePath": "/absolute/path/to/pfx"
},
- "WebSocketEndpoint": {
+ "WebSocketEndPoint": {
"Enabled": true,
"Path": "/mqtt",
"KeepAliveInterval": 120, // In seconds.