From 7067a8e411395feee075848d579a7d01246664d1 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 20 Sep 2017 23:22:12 +0200 Subject: [PATCH 1/7] Create .bettercodehub.yml --- .bettercodehub.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .bettercodehub.yml diff --git a/.bettercodehub.yml b/.bettercodehub.yml new file mode 100644 index 0000000..56a8cef --- /dev/null +++ b/.bettercodehub.yml @@ -0,0 +1,7 @@ +exclude: +- /MQTTnet.TestApp.NetCore/Program.cs +- /Tests/MQTTnet.TestApp.NetFramework/.* +- /Tests/MQTTnet.TestApp.UniversalWindows/.* +component_depth: 1 +languages: +- csharp From fb272b07aaaa7f9866b987e4187b6b5b40755aef Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 20 Sep 2017 23:25:35 +0200 Subject: [PATCH 2/7] Update .bettercodehub.yml --- .bettercodehub.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bettercodehub.yml b/.bettercodehub.yml index 56a8cef..a24cd28 100644 --- a/.bettercodehub.yml +++ b/.bettercodehub.yml @@ -1,4 +1,5 @@ exclude: +- /Frameworks/.* - /MQTTnet.TestApp.NetCore/Program.cs - /Tests/MQTTnet.TestApp.NetFramework/.* - /Tests/MQTTnet.TestApp.UniversalWindows/.* From ea587d97c8cd8e02326da97f751eb60a604c17b1 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Wed, 20 Sep 2017 23:31:09 +0200 Subject: [PATCH 3/7] Organize solution --- MQTTnet.sln | 38 +++++++++---------- .../MQTTnet.TestApp.NetCore.csproj | 4 +- .../MQTTnet.TestApp.NetCore}/Program.cs | 0 3 files changed, 21 insertions(+), 21 deletions(-) rename {MQTTnet.TestApp.NetCore => Tests/MQTTnet.TestApp.NetCore}/MQTTnet.TestApp.NetCore.csproj (57%) rename {MQTTnet.TestApp.NetCore => Tests/MQTTnet.TestApp.NetCore}/Program.cs (100%) diff --git a/MQTTnet.sln b/MQTTnet.sln index 4ad2ba6..2789163 100644 --- a/MQTTnet.sln +++ b/MQTTnet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.Core.Tests", "Tests\MQTTnet.Core.Tests\MQTTnet.Core.Tests.csproj", "{A7FF0C91-25DE-4BA6-B39E-F54E8DADF1CC}" EndProject @@ -32,7 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MQTTnet.TestApp.NetCore", "MQTTnet.TestApp.NetCore\MQTTnet.TestApp.NetCore.csproj", "{4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.TestApp.NetCore", "Tests\MQTTnet.TestApp.NetCore\MQTTnet.TestApp.NetCore.csproj", "{3D283AAD-AAA8-4339-8394-52F80B6304DB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -164,22 +164,22 @@ Global {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x64.Build.0 = Release|Any CPU {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x86.ActiveCfg = Release|Any CPU {3587E506-55A2-4EB3-99C7-DC01E42D25D2}.Release|x86.Build.0 = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|ARM.ActiveCfg = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|ARM.Build.0 = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|x64.ActiveCfg = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|x64.Build.0 = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|x86.ActiveCfg = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Debug|x86.Build.0 = Debug|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|Any CPU.Build.0 = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|ARM.ActiveCfg = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|ARM.Build.0 = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|x64.ActiveCfg = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|x64.Build.0 = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|x86.ActiveCfg = Release|Any CPU - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453}.Release|x86.Build.0 = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|ARM.Build.0 = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|x64.ActiveCfg = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|x64.Build.0 = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Debug|x86.Build.0 = Debug|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|Any CPU.Build.0 = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|ARM.ActiveCfg = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|ARM.Build.0 = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|x64.ActiveCfg = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|x64.Build.0 = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|x86.ActiveCfg = Release|Any CPU + {3D283AAD-AAA8-4339-8394-52F80B6304DB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -191,7 +191,7 @@ Global {D9D74F33-6943-49B2-B765-7BD589082098} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} {FF1F72D6-9524-4422-9497-3CC0002216ED} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} {3587E506-55A2-4EB3-99C7-DC01E42D25D2} = {32A630A7-2598-41D7-B625-204CD906F5FB} - {4094DDF0-1DFB-4FA7-A2FA-AD5A44545453} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} + {3D283AAD-AAA8-4339-8394-52F80B6304DB} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {07536672-5CBC-4BE3-ACE0-708A431A7894} diff --git a/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj similarity index 57% rename from MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj rename to Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj index 7bbbb86..5871b1e 100644 --- a/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj +++ b/Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/MQTTnet.TestApp.NetCore/Program.cs b/Tests/MQTTnet.TestApp.NetCore/Program.cs similarity index 100% rename from MQTTnet.TestApp.NetCore/Program.cs rename to Tests/MQTTnet.TestApp.NetCore/Program.cs From 37a5dc7abefdc3878fd58f12220c8fa84baa1078 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 21 Sep 2017 11:48:05 +0200 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3805e8b..167cb06 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ MQTTnet is a .NET library for MQTT based communication. It provides a MQTT clien * Access to internal trace messages * Unit tested (57+ tests) -\* Tested on local machine with MQTTnet client and server running in the same process and using TCP channel. +\* Tested on local machine with MQTTnet client and server running on the same machine using the TCP channel. ### Client * Rx support (via another project) From 07fd509e74351b6c111645db5676a09f0d86a1c3 Mon Sep 17 00:00:00 2001 From: 1iveowl Date: Sun, 24 Sep 2017 16:19:59 +0200 Subject: [PATCH 5/7] Bug fixes --- Build/MQTTnet.nuspec | 2 +- .../MQTTnet.Netstandard.csproj | 2 +- .../MQTTnet.UniversalWindows.csproj | 5 --- .../MqttChannelCommunicationAdapter.cs | 34 +++++++++++-------- MQTTnet.Core/Client/MqttClient.cs | 1 + 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index a6c5cb7..e1ab120 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -24,7 +24,7 @@ - + diff --git a/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj index 25aaef0..c64ae22 100644 --- a/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj +++ b/Frameworks/MQTTnet.NetStandard/MQTTnet.Netstandard.csproj @@ -23,7 +23,7 @@ - + diff --git a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj index b042a77..0d40ac2 100644 --- a/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj +++ b/Frameworks/MQTTnet.UniversalWindows/MQTTnet.UniversalWindows.csproj @@ -130,11 +130,6 @@ 5.4.0 - - - ..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Net.Security.dll - - 14.0 diff --git a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs index 89e9576..f439a52 100644 --- a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs +++ b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs @@ -83,35 +83,39 @@ namespace MQTTnet.Core.Adapter { foreach (var packet in packets) { - MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), "TX >>> {0} [Timeout={1}]", packet, timeout); + if (packet == null) continue; + + MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), $"TX >>> {packet} [Timeout={timeout}]"); var writeBuffer = PacketSerializer.Serialize(packet); _sendTask = _sendTask.ContinueWith(p => _channel.SendStream.WriteAsync(writeBuffer, 0, writeBuffer.Length, cancellationToken).ConfigureAwait(false), cancellationToken); } + + if (timeout > TimeSpan.Zero) + { + _sendTask = _sendTask.ContinueWith(c => _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout), cancellationToken);// _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout);//.ConfigureAwait(false); + } + else + { + _sendTask = _sendTask.ContinueWith(c => _channel.SendStream.FlushAsync(cancellationToken), cancellationToken); + } + } await _sendTask; // configure await false generates stackoverflow - if (timeout > TimeSpan.Zero) - { - await _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout).ConfigureAwait(false); - } - else - { - await _channel.SendStream.FlushAsync(cancellationToken).ConfigureAwait(false); - } } - catch (TaskCanceledException) + catch (TaskCanceledException ex) { - throw; + throw ex; } - catch (MqttCommunicationTimedOutException) + catch (MqttCommunicationTimedOutException ex) { - throw; + throw ex; } - catch (MqttCommunicationException) + catch (MqttCommunicationException ex) { - throw; + throw ex; } catch (Exception exception) { diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index 8be6450..3f0b4e6 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -63,6 +63,7 @@ namespace MQTTnet.Core.Client }; var response = await SendAndReceiveAsync(connectPacket).ConfigureAwait(false); + if (response.ConnectReturnCode != MqttConnectReturnCode.ConnectionAccepted) { throw new MqttConnectingFailedException(response.ConnectReturnCode); From 28d31d0cf52022808096d58e04d24759750d7544 Mon Sep 17 00:00:00 2001 From: 1iveowl Date: Sun, 24 Sep 2017 17:03:29 +0200 Subject: [PATCH 6/7] Increased PR quality --- .../Adapter/MqttChannelCommunicationAdapter.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs index f439a52..8eb47a9 100644 --- a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs +++ b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs @@ -83,7 +83,7 @@ namespace MQTTnet.Core.Adapter { foreach (var packet in packets) { - if (packet == null) continue; + if (packet == null) {continue}; MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), $"TX >>> {packet} [Timeout={timeout}]"); @@ -93,7 +93,7 @@ namespace MQTTnet.Core.Adapter if (timeout > TimeSpan.Zero) { - _sendTask = _sendTask.ContinueWith(c => _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout), cancellationToken);// _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout);//.ConfigureAwait(false); + _sendTask = _sendTask.ContinueWith(c => _channel.SendStream.FlushAsync(cancellationToken).TimeoutAfter(timeout), cancellationToken).ConfigureAwait(false); } else { @@ -105,17 +105,17 @@ namespace MQTTnet.Core.Adapter await _sendTask; // configure await false generates stackoverflow } - catch (TaskCanceledException ex) + catch (TaskCanceledException) { - throw ex; + throw; } - catch (MqttCommunicationTimedOutException ex) + catch (MqttCommunicationTimedOutException) { - throw ex; + throw; } - catch (MqttCommunicationException ex) + catch (MqttCommunicationException) { - throw ex; + throw; } catch (Exception exception) { @@ -190,4 +190,4 @@ namespace MQTTnet.Core.Adapter return new ReceivedMqttPacket(header, new MemoryStream(body, 0, body.Length)); } } -} \ No newline at end of file +} From 6d92937892866cc7150888bc2ae0fd56ddf7fb76 Mon Sep 17 00:00:00 2001 From: 1iveowl Date: Sun, 24 Sep 2017 17:06:41 +0200 Subject: [PATCH 7/7] Fixed typo --- MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs index 8eb47a9..90ec842 100644 --- a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs +++ b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs @@ -83,7 +83,7 @@ namespace MQTTnet.Core.Adapter { foreach (var packet in packets) { - if (packet == null) {continue}; + if (packet == null) {continue; } MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), $"TX >>> {packet} [Timeout={timeout}]");