@@ -2,7 +2,7 @@ | |||||
<package > | <package > | ||||
<metadata> | <metadata> | ||||
<id>MQTTnet</id> | <id>MQTTnet</id> | ||||
<version>2.1.5</version> | |||||
<version>2.1.5.1</version> | |||||
<authors>Christian Kratky</authors> | <authors>Christian Kratky</authors> | ||||
<owners>Christian Kratky</owners> | <owners>Christian Kratky</owners> | ||||
<licenseUrl>https://github.com/chkr1011/MQTTnet/blob/master/LICENSE</licenseUrl> | <licenseUrl>https://github.com/chkr1011/MQTTnet/blob/master/LICENSE</licenseUrl> | ||||
@@ -10,11 +10,7 @@ | |||||
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> | <iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl> | ||||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||||
<description>MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description> | <description>MQTTnet is a .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description> | ||||
<releaseNotes>* [MqttServer] Added support for publishing application messages | |||||
* [Core] Fixed QoS level 2 handling | |||||
* [Core] Performance optimizations | |||||
* [MqttClient/MqttServer] Errors while handline application messages are now catched and traced | |||||
* [MqttClient/MqttServer] Added interfaces | |||||
<releaseNotes>* [Server] Fixed wrong handling of QoS levels | |||||
</releaseNotes> | </releaseNotes> | ||||
<copyright>Copyright Christian Kratky 2016-2017</copyright> | <copyright>Copyright Christian Kratky 2016-2017</copyright> | ||||
<tags>MQTT MQTTClient MQTTServer MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Queue Hardware</tags> | <tags>MQTT MQTTClient MQTTServer MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Queue Hardware</tags> | ||||
@@ -86,7 +86,7 @@ namespace MQTTnet.Implementations | |||||
try | try | ||||
{ | { | ||||
var clientSocket = await Task.Factory.FromAsync(_defaultEndpointSocket.BeginAccept, _defaultEndpointSocket.EndAccept, null); | var clientSocket = await Task.Factory.FromAsync(_defaultEndpointSocket.BeginAccept, _defaultEndpointSocket.EndAccept, null); | ||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new DefaultMqttV311PacketSerializer()); | |||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new MqttV311PacketSerializer()); | |||||
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ||||
} | } | ||||
catch (Exception exception) when (!(exception is ObjectDisposedException)) | catch (Exception exception) when (!(exception is ObjectDisposedException)) | ||||
@@ -107,7 +107,7 @@ namespace MQTTnet.Implementations | |||||
var sslStream = new SslStream(new NetworkStream(clientSocket)); | var sslStream = new SslStream(new NetworkStream(clientSocket)); | ||||
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false); | await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false); | ||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream), new DefaultMqttV311PacketSerializer()); | |||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream), new MqttV311PacketSerializer()); | |||||
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ||||
} | } | ||||
catch (Exception exception) | catch (Exception exception) | ||||
@@ -12,7 +12,7 @@ namespace MQTTnet | |||||
{ | { | ||||
if (options == null) throw new ArgumentNullException(nameof(options)); | if (options == null) throw new ArgumentNullException(nameof(options)); | ||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new DefaultMqttV311PacketSerializer())); | |||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new MqttV311PacketSerializer())); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices; | |||||
[assembly: AssemblyCulture("")] | [assembly: AssemblyCulture("")] | ||||
[assembly: ComVisible(false)] | [assembly: ComVisible(false)] | ||||
[assembly: Guid("a480ef90-0eaa-4d9a-b271-47a9c47f6f7d")] | [assembly: Guid("a480ef90-0eaa-4d9a-b271-47a9c47f6f7d")] | ||||
[assembly: AssemblyVersion("2.1.4.0")] | |||||
[assembly: AssemblyFileVersion("2.1.4.0")] | |||||
[assembly: AssemblyVersion("2.1.5.1")] | |||||
[assembly: AssemblyFileVersion("2.1.5.1")] |
@@ -84,7 +84,7 @@ namespace MQTTnet.Implementations | |||||
try | try | ||||
{ | { | ||||
var clientSocket = await _defaultEndpointSocket.AcceptAsync(); | var clientSocket = await _defaultEndpointSocket.AcceptAsync(); | ||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new DefaultMqttV311PacketSerializer()); | |||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new MqttV311PacketSerializer()); | |||||
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ||||
} | } | ||||
catch (Exception exception) | catch (Exception exception) | ||||
@@ -105,7 +105,7 @@ namespace MQTTnet.Implementations | |||||
var sslStream = new SslStream(new NetworkStream(clientSocket)); | var sslStream = new SslStream(new NetworkStream(clientSocket)); | ||||
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false); | await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false); | ||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream), new DefaultMqttV311PacketSerializer()); | |||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream), new MqttV311PacketSerializer()); | |||||
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter)); | ||||
} | } | ||||
catch (Exception exception) | catch (Exception exception) | ||||
@@ -4,8 +4,8 @@ | |||||
<TargetFramework>netstandard1.3</TargetFramework> | <TargetFramework>netstandard1.3</TargetFramework> | ||||
<AssemblyName>MQTTnet</AssemblyName> | <AssemblyName>MQTTnet</AssemblyName> | ||||
<RootNamespace>MQTTnet</RootNamespace> | <RootNamespace>MQTTnet</RootNamespace> | ||||
<AssemblyVersion>2.1.4.0</AssemblyVersion> | |||||
<FileVersion>2.1.4.0</FileVersion> | |||||
<AssemblyVersion>2.1.5.1</AssemblyVersion> | |||||
<FileVersion>2.1.5.1</FileVersion> | |||||
<Version>0.0.0.0</Version> | <Version>0.0.0.0</Version> | ||||
<Company /> | <Company /> | ||||
<Product /> | <Product /> | ||||
@@ -12,7 +12,7 @@ namespace MQTTnet | |||||
{ | { | ||||
if (options == null) throw new ArgumentNullException(nameof(options)); | if (options == null) throw new ArgumentNullException(nameof(options)); | ||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new DefaultMqttV311PacketSerializer())); | |||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new MqttV311PacketSerializer())); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -52,7 +52,7 @@ namespace MQTTnet.Implementations | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(args.Socket), new DefaultMqttV311PacketSerializer()); | |||||
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(args.Socket), new MqttV311PacketSerializer()); | |||||
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(args.Socket.Information.RemoteAddress.ToString(), clientAdapter)); | ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(args.Socket.Information.RemoteAddress.ToString(), clientAdapter)); | ||||
} | } | ||||
catch (Exception exception) | catch (Exception exception) | ||||
@@ -12,7 +12,7 @@ namespace MQTTnet | |||||
{ | { | ||||
if (options == null) throw new ArgumentNullException(nameof(options)); | if (options == null) throw new ArgumentNullException(nameof(options)); | ||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new DefaultMqttV311PacketSerializer())); | |||||
return new MqttClient(options, new MqttChannelCommunicationAdapter(new MqttTcpChannel(), new MqttV311PacketSerializer())); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -10,5 +10,5 @@ using System.Runtime.InteropServices; | |||||
[assembly: AssemblyTrademark("")] | [assembly: AssemblyTrademark("")] | ||||
[assembly: AssemblyCulture("")] | [assembly: AssemblyCulture("")] | ||||
[assembly: ComVisible(false)] | [assembly: ComVisible(false)] | ||||
[assembly: AssemblyVersion("2.1.4.0")] | |||||
[assembly: AssemblyFileVersion("2.1.4.0")] | |||||
[assembly: AssemblyVersion("2.1.5.1")] | |||||
[assembly: AssemblyFileVersion("2.1.5.1")] |
@@ -267,7 +267,7 @@ namespace MQTTnet.Core.Client | |||||
return SendAsync(new MqttPubRecPacket { PacketIdentifier = publishPacket.PacketIdentifier }); | return SendAsync(new MqttPubRecPacket { PacketIdentifier = publishPacket.PacketIdentifier }); | ||||
} | } | ||||
throw new InvalidOperationException(); | |||||
throw new MqttCommunicationException("Received a not supported QoS level."); | |||||
} | } | ||||
private async Task ProcessReceivedPubRelPacket(MqttPubRelPacket pubRelPacket) | private async Task ProcessReceivedPubRelPacket(MqttPubRelPacket pubRelPacket) | ||||
@@ -16,8 +16,8 @@ | |||||
<PackageIconUrl></PackageIconUrl> | <PackageIconUrl></PackageIconUrl> | ||||
<RepositoryUrl></RepositoryUrl> | <RepositoryUrl></RepositoryUrl> | ||||
<PackageTags></PackageTags> | <PackageTags></PackageTags> | ||||
<FileVersion>2.1.4.0</FileVersion> | |||||
<AssemblyVersion>2.1.4.0</AssemblyVersion> | |||||
<FileVersion>2.1.5.1</FileVersion> | |||||
<AssemblyVersion>2.1.5.1</AssemblyVersion> | |||||
<PackageLicenseUrl></PackageLicenseUrl> | <PackageLicenseUrl></PackageLicenseUrl> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
@@ -9,8 +9,10 @@ using MQTTnet.Core.Protocol; | |||||
namespace MQTTnet.Core.Serializer | namespace MQTTnet.Core.Serializer | ||||
{ | { | ||||
public sealed class DefaultMqttV311PacketSerializer : IMqttPacketSerializer | |||||
public sealed class MqttV311PacketSerializer : IMqttPacketSerializer | |||||
{ | { | ||||
private static readonly byte[] MqttV311Prefix = Encoding.UTF8.GetBytes("MQTT"); | |||||
public Task SerializeAsync(MqttBasePacket packet, IMqttCommunicationChannel destination) | public Task SerializeAsync(MqttBasePacket packet, IMqttCommunicationChannel destination) | ||||
{ | { | ||||
if (packet == null) throw new ArgumentNullException(nameof(packet)); | if (packet == null) throw new ArgumentNullException(nameof(packet)); | ||||
@@ -351,8 +353,6 @@ namespace MQTTnet.Core.Serializer | |||||
} | } | ||||
} | } | ||||
private static readonly byte[] MqttPrefix = Encoding.UTF8.GetBytes("MQTT"); | |||||
private static Task SerializeAsync(MqttConnectPacket packet, IMqttCommunicationChannel destination) | private static Task SerializeAsync(MqttConnectPacket packet, IMqttCommunicationChannel destination) | ||||
{ | { | ||||
ValidateConnectPacket(packet); | ValidateConnectPacket(packet); | ||||
@@ -361,7 +361,7 @@ namespace MQTTnet.Core.Serializer | |||||
{ | { | ||||
// Write variable header | // Write variable header | ||||
output.Write(0x00, 0x04); // 3.1.2.1 Protocol Name | output.Write(0x00, 0x04); // 3.1.2.1 Protocol Name | ||||
output.Write(MqttPrefix); | |||||
output.Write(MqttV311Prefix); | |||||
output.Write(0x04); // 3.1.2.2 Protocol Level | output.Write(0x04); // 3.1.2.2 Protocol Level | ||||
var connectFlags = new ByteWriter(); // 3.1.2.3 Connect Flags | var connectFlags = new ByteWriter(); // 3.1.2.3 Connect Flags |
@@ -153,13 +153,16 @@ namespace MQTTnet.Core.Server | |||||
if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.AtMostOnce) | if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.AtMostOnce) | ||||
{ | { | ||||
_publishPacketReceivedCallback(this, publishPacket); | _publishPacketReceivedCallback(this, publishPacket); | ||||
return Task.FromResult(0); | |||||
} | } | ||||
else if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.AtLeastOnce) | |||||
if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.AtLeastOnce) | |||||
{ | { | ||||
_publishPacketReceivedCallback(this, publishPacket); | _publishPacketReceivedCallback(this, publishPacket); | ||||
return _adapter.SendPacketAsync(new MqttPubAckPacket { PacketIdentifier = publishPacket.PacketIdentifier }, _options.DefaultCommunicationTimeout); | return _adapter.SendPacketAsync(new MqttPubAckPacket { PacketIdentifier = publishPacket.PacketIdentifier }, _options.DefaultCommunicationTimeout); | ||||
} | } | ||||
else if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.ExactlyOnce) | |||||
if (publishPacket.QualityOfServiceLevel == MqttQualityOfServiceLevel.ExactlyOnce) | |||||
{ | { | ||||
// QoS 2 is implement as method "B" [4.3.3 QoS 2: Exactly once delivery] | // QoS 2 is implement as method "B" [4.3.3 QoS 2: Exactly once delivery] | ||||
lock (_unacknowledgedPublishPackets) | lock (_unacknowledgedPublishPackets) | ||||
@@ -172,7 +175,7 @@ namespace MQTTnet.Core.Server | |||||
return _adapter.SendPacketAsync(new MqttPubRecPacket { PacketIdentifier = publishPacket.PacketIdentifier }, _options.DefaultCommunicationTimeout); | return _adapter.SendPacketAsync(new MqttPubRecPacket { PacketIdentifier = publishPacket.PacketIdentifier }, _options.DefaultCommunicationTimeout); | ||||
} | } | ||||
throw new MqttCommunicationException("Received not supported QoS level."); | |||||
throw new MqttCommunicationException("Received a not supported QoS level."); | |||||
} | } | ||||
private Task HandleIncomingPubRelPacketAsync(MqttPubRelPacket pubRelPacket) | private Task HandleIncomingPubRelPacketAsync(MqttPubRelPacket pubRelPacket) | ||||
@@ -405,7 +405,7 @@ namespace MQTTnet.Core.Tests | |||||
private void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value) | private void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value) | ||||
{ | { | ||||
var serializer = new DefaultMqttV311PacketSerializer(); | |||||
var serializer = new MqttV311PacketSerializer(); | |||||
var channel = new TestChannel(); | var channel = new TestChannel(); | ||||
serializer.SerializeAsync(packet, channel).Wait(); | serializer.SerializeAsync(packet, channel).Wait(); | ||||
var buffer = channel.ToArray(); | var buffer = channel.ToArray(); | ||||
@@ -415,7 +415,7 @@ namespace MQTTnet.Core.Tests | |||||
private void DeserializeAndCompare(MqttBasePacket packet, string expectedBase64Value) | private void DeserializeAndCompare(MqttBasePacket packet, string expectedBase64Value) | ||||
{ | { | ||||
var serializer = new DefaultMqttV311PacketSerializer(); | |||||
var serializer = new MqttV311PacketSerializer(); | |||||
var channel1 = new TestChannel(); | var channel1 = new TestChannel(); | ||||
serializer.SerializeAsync(packet, channel1).Wait(); | serializer.SerializeAsync(packet, channel1).Wait(); | ||||