diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec
index 5977775..1e14f0d 100644
--- a/Build/MQTTnet.nuspec
+++ b/Build/MQTTnet.nuspec
@@ -17,6 +17,7 @@
* [Server] Refactoring of server certificate password classes (BREAKING CHANGE!).
* [Server] Fixed an issue with empty server certificate passwords (thanks to @SeppPenner).
* [MQTTnet.Server] Added support for certificate passwords (BREAKING CHANGE IN CONFIG!)
+* [MQTTnet.AspNetCore] fixed an issue with mqtt V5 package serialization (#743)
Copyright Christian Kratky 2016-2019
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/SpanBasedMqttPacketWriter.cs b/Source/MQTTnet.AspnetCore/SpanBasedMqttPacketWriter.cs
index 27e13c4..66addfd 100644
--- a/Source/MQTTnet.AspnetCore/SpanBasedMqttPacketWriter.cs
+++ b/Source/MQTTnet.AspnetCore/SpanBasedMqttPacketWriter.cs
@@ -64,7 +64,6 @@ namespace MQTTnet.AspNetCore
GrowIfNeeded(propertyWriter.Length);
Write(propertyWriter.GetBuffer(), 0, propertyWriter.Length);
- Commit(propertyWriter.Length);
}
public void Write(byte[] payload, int start, int length)
diff --git a/Tests/MQTTnet.Core.Tests/MqttPacketSerializer_Tests.cs b/Tests/MQTTnet.Core.Tests/MqttPacketSerializer_Tests.cs
index b67d2a2..a1f798a 100644
--- a/Tests/MQTTnet.Core.Tests/MqttPacketSerializer_Tests.cs
+++ b/Tests/MQTTnet.Core.Tests/MqttPacketSerializer_Tests.cs
@@ -8,6 +8,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using MQTTnet.Adapter;
using MQTTnet.Formatter;
using MQTTnet.Formatter.V3;
+using MQTTnet.Formatter.V5;
using MQTTnet.Internal;
using MQTTnet.Packets;
using MQTTnet.Protocol;
@@ -258,6 +259,26 @@ namespace MQTTnet.Tests
Assert.IsTrue(deserialized.Properties.UserProperties.Any(x => x.Name == "Foo"));
}
+
+ [TestMethod]
+ public void SerializeV500_MqttPublishPacket_CorrelationData()
+ {
+ var data = "123456789";
+ var req = new MqttApplicationMessageBuilder()
+ .WithTopic("Foo")
+ .WithResponseTopic($"_")
+ .WithCorrelationData(Guid.NewGuid().ToByteArray())
+ .WithPayload(data)
+ .WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtMostOnce)
+ .Build();
+
+ var p = new MqttV500DataConverter().CreatePublishPacket(req);
+
+ var deserialized = Roundtrip(p, MqttProtocolVersion.V500);
+
+ Assert.IsTrue(p.Payload.SequenceEqual(deserialized.Payload));
+ }
+
[TestMethod]
public void DeserializeV311_MqttPublishPacket()
{