diff --git a/Build/MQTTnet.AspNetCore.nuspec b/Build/MQTTnet.AspNetCore.nuspec
index cb1718f..8809fac 100644
--- a/Build/MQTTnet.AspNetCore.nuspec
+++ b/Build/MQTTnet.AspNetCore.nuspec
@@ -10,7 +10,8 @@
https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png
false
This is a support library to integrate MQTTnet into AspNetCore.
- * For more release notes please check the MQTTnet release notes.
+ * For more release notes please check the MQTTnet release notes.
+ * [Server] fixed cpu spike in case a client disconnectes (issue 421)
Copyright Christian Kratky 2016-2018
MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
diff --git a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
index 8a8469d..361eb6a 100644
--- a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
+++ b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Connections;
using MQTTnet.Adapter;
using MQTTnet.AspNetCore.Client.Tcp;
+using MQTTnet.Exceptions;
using MQTTnet.Packets;
using MQTTnet.Serializer;
using System;
@@ -83,7 +84,7 @@ namespace MQTTnet.AspNetCore
}
else if (readResult.IsCompleted)
{
- break;
+ throw new MqttCommunicationException("Connection Aborted");
}
}
finally
diff --git a/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj b/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
index 77dfff9..f45b4fb 100644
--- a/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
+++ b/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
@@ -1,4 +1,4 @@
-
+
netcoreapp2.1
@@ -7,9 +7,9 @@
-
-
-
+
+
+
diff --git a/Tests/MQTTnet.AspNetCore.Tests/Mockups/ConnectionContextMockup.cs b/Tests/MQTTnet.AspNetCore.Tests/Mockups/ConnectionContextMockup.cs
new file mode 100644
index 0000000..296959e
--- /dev/null
+++ b/Tests/MQTTnet.AspNetCore.Tests/Mockups/ConnectionContextMockup.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using System.IO.Pipelines;
+using Microsoft.AspNetCore.Connections;
+using Microsoft.AspNetCore.Http.Features;
+
+namespace MQTTnet.AspNetCore.Tests.Mockups
+{
+ public class ConnectionContextMockup : ConnectionContext
+ {
+ public override string ConnectionId { get; set; }
+
+ public override IFeatureCollection Features { get; }
+
+ public override IDictionary