diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec
index 86992c5..a7902e0 100644
--- a/Build/MQTTnet.nuspec
+++ b/Build/MQTTnet.nuspec
@@ -11,7 +11,9 @@
false
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).
-* [Server] Fixed a bug which returns wrong flag for existing sessions (thanks to @avengerstark).
+* [Core] Fixed missing properties from PUBLISH packet in _MqttApplicationMessage_ (thanks to @pcbing).
+* [Core] Fixed wrong encoding of PUBREL and PUBCOMP packets for MQTTv5 (thanks to @perphilipp).
+* [Server] Fixed a bug which returns wrong flag for existing session in CONNACK packet (thanks to @avengerstark).
* [nuget] .NET Framework builds are now using 4.5.2 or 4.6.1 builds instead of netstandard 2.0.
Copyright Christian Kratky 2016-2019
diff --git a/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs b/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs
index 8071fc3..3866dd8 100644
--- a/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs
+++ b/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs
@@ -63,6 +63,13 @@ namespace MQTTnet.Formatter.V5
Payload = publishPacket.Payload,
QualityOfServiceLevel = publishPacket.QualityOfServiceLevel,
Retain = publishPacket.Retain,
+ ResponseTopic = publishPacket.Properties?.ResponseTopic,
+ ContentType = publishPacket.Properties?.ContentType,
+ CorrelationData = publishPacket.Properties?.CorrelationData,
+ MessageExpiryInterval = publishPacket.Properties?.MessageExpiryInterval,
+ SubscriptionIdentifier = publishPacket.Properties?.SubscriptionIdentifier,
+ TopicAlias = publishPacket.Properties?.TopicAlias,
+ PayloadFormatIndicator = publishPacket.Properties?.PayloadFormatIndicator,
UserProperties = publishPacket.Properties?.UserProperties ?? new List()
};
}
diff --git a/Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs b/Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs
index 5800d30..acb4202 100644
--- a/Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs
+++ b/Source/MQTTnet/Formatter/V5/MqttV500PacketEncoder.cs
@@ -343,9 +343,6 @@ namespace MQTTnet.Formatter.V5
ThrowReasonCodeNotSetException();
}
- packetWriter.Write(packet.PacketIdentifier.Value);
- packetWriter.Write((byte)packet.ReasonCode.Value);
-
var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
{
@@ -353,7 +350,9 @@ namespace MQTTnet.Formatter.V5
propertiesWriter.WriteUserProperties(packet.Properties.UserProperties);
}
- if (packetWriter.Length > 0 || packet.ReasonCode.Value != MqttPubRelReasonCode.Success)
+ packetWriter.Write(packet.PacketIdentifier.Value);
+
+ if (propertiesWriter.Length > 0 || packet.ReasonCode.Value != MqttPubRelReasonCode.Success)
{
packetWriter.Write((byte)packet.ReasonCode.Value);
propertiesWriter.WriteToPacket(packetWriter);
@@ -372,8 +371,7 @@ namespace MQTTnet.Formatter.V5
}
packetWriter.Write(packet.PacketIdentifier.Value);
- packetWriter.Write((byte)packet.ReasonCode.Value);
-
+
var propertiesWriter = new MqttV500PropertiesWriter();
if (packet.Properties != null)
{
@@ -381,7 +379,7 @@ namespace MQTTnet.Formatter.V5
propertiesWriter.WriteUserProperties(packet.Properties.UserProperties);
}
- if (packetWriter.Length > 0 || packet.ReasonCode.Value != MqttPubCompReasonCode.Success)
+ if (propertiesWriter.Length > 0 || packet.ReasonCode.Value != MqttPubCompReasonCode.Success)
{
packetWriter.Write((byte)packet.ReasonCode.Value);
propertiesWriter.WriteToPacket(packetWriter);
diff --git a/Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs b/Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs
index 9e5fe39..a7cb89f 100644
--- a/Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs
+++ b/Source/MQTTnet/Formatter/V5/MqttV500PropertiesWriter.cs
@@ -7,8 +7,11 @@ namespace MQTTnet.Formatter.V5
{
public class MqttV500PropertiesWriter
{
+ // TODO: Consider lazy init on first write to avoid useless allocations.
private readonly MqttPacketWriter _packetWriter = new MqttPacketWriter();
+ public int Length => _packetWriter.Length;
+
public void WriteUserProperties(List userProperties)
{
if (userProperties == null || userProperties.Count == 0)