Parcourir la source

Merge pull request #430 from JanEggers/fix#421

fixed #421
release/3.x.x
Christian il y a 6 ans
committed by GitHub
Parent
révision
b819746165
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
7 fichiers modifiés avec 76 ajouts et 7 suppressions
  1. +2
    -1
      Build/MQTTnet.AspNetCore.nuspec
  2. +2
    -1
      Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
  3. +4
    -4
      Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
  4. +22
    -0
      Tests/MQTTnet.AspNetCore.Tests/Mockups/ConnectionContextMockup.cs
  5. +16
    -0
      Tests/MQTTnet.AspNetCore.Tests/Mockups/DuplexPipeMockup.cs
  6. +29
    -0
      Tests/MQTTnet.AspNetCore.Tests/MqttConnectionContextTest.cs
  7. +1
    -1
      Tests/MQTTnet.Core.Tests/MQTTnet.Core.Tests.csproj

+ 2
- 1
Build/MQTTnet.AspNetCore.nuspec Voir le fichier

@@ -10,7 +10,8 @@
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is a support library to integrate MQTTnet into AspNetCore.</description>
<releaseNotes>* For more release notes please check the MQTTnet release notes.
<releaseNotes> * For more release notes please check the MQTTnet release notes.
* [Server] fixed cpu spike in case a client disconnectes (issue 421)
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2018</copyright>
<tags>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</tags>


+ 2
- 1
Source/MQTTnet.AspnetCore/MqttConnectionContext.cs Voir le fichier

@@ -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


+ 4
- 4
Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj Voir le fichier

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
@@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
</ItemGroup>

<ItemGroup>


+ 22
- 0
Tests/MQTTnet.AspNetCore.Tests/Mockups/ConnectionContextMockup.cs Voir le fichier

@@ -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<object, object> Items { get; set; }
public override IDuplexPipe Transport { get; set; }

public ConnectionContextMockup()
{
//Transport = new DefaultConnectionContext
}
}
}

+ 16
- 0
Tests/MQTTnet.AspNetCore.Tests/Mockups/DuplexPipeMockup.cs Voir le fichier

@@ -0,0 +1,16 @@
using System.IO.Pipelines;

namespace MQTTnet.AspNetCore.Tests.Mockups
{
public class DuplexPipeMockup : IDuplexPipe
{
PipeReader IDuplexPipe.Input => Receive.Reader;

PipeWriter IDuplexPipe.Output => Send.Writer;


public Pipe Receive { get; set; } = new Pipe();

public Pipe Send { get; set; } = new Pipe();
}
}

+ 29
- 0
Tests/MQTTnet.AspNetCore.Tests/MqttConnectionContextTest.cs Voir le fichier

@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Connections;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MQTTnet.AspNetCore.Tests.Mockups;
using MQTTnet.Exceptions;
using MQTTnet.Serializer;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace MQTTnet.AspNetCore.Tests
{
[TestClass]
public class MqttConnectionContextTest
{
[TestMethod]
public async Task TestReceivePacketAsyncThrowsWhenReaderCompleted()
{
var serializer = new MqttPacketSerializer {};
var pipe = new DuplexPipeMockup();
var connection = new DefaultConnectionContext();
connection.Transport = pipe;
var ctx = new MqttConnectionContext(serializer, connection);

pipe.Receive.Writer.Complete();

await Assert.ThrowsExceptionAsync<MqttCommunicationException>(() => ctx.ReceivePacketAsync(TimeSpan.FromSeconds(1), CancellationToken.None));
}
}
}

+ 1
- 1
Tests/MQTTnet.Core.Tests/MQTTnet.Core.Tests.csproj Voir le fichier

@@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
</ItemGroup>

<ItemGroup>


Chargement…
Annuler
Enregistrer