mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 02:53:06 +08:00
Fix null ref exception in low level client.
This commit is contained in:
@@ -12,12 +12,13 @@
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker) and supports v3.1.0, v3.1.1 and v5.0.0 of the MQTT protocol.</description>
|
||||
<releaseNotes>
|
||||
* [RcpClient] Adjusted some namespaces (BREAKING CHANGE!)
|
||||
* [AspNetCore] Adjusted some namespaces (BREAKING CHANGE!)
|
||||
* [Server] Adjusted some namespaces (BREAKING CHANGE!)
|
||||
* [LowLevelClient] Fixed a null reference exception when connecting to a not existing server (thanks to @SGStino).
|
||||
* [RcpClient] Adjusted some namespaces (BREAKING CHANGE!).
|
||||
* [AspNetCore] Adjusted some namespaces (BREAKING CHANGE!).
|
||||
* [Server] Adjusted some namespaces (BREAKING CHANGE!).
|
||||
* [Server] Added state checks (throw if not started etc.) for most server APIs.
|
||||
* [Server] Exposed real X509Certificate2 (instead byte array) to TLS options (thanks to @borigas).
|
||||
* [Server] Fixed memory leak with TCP sockets (MqttServer is now Disposable!) (BREAKING CHANGE!)
|
||||
* [Server] Fixed memory leak with TCP sockets (MqttServer is now Disposable!) (BREAKING CHANGE!).
|
||||
* [Core] Fixed a null reference exception in the MqttTcpChannel with WriteAsync and ReadAsync.
|
||||
* [Core] Added server interceptor for undelivered messages (thanks to @cshark-inator).
|
||||
* [nuget] Added support for SourceLink (thanks to @JTOne123).
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace MQTTnet.LowLevelClient
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_adapter.Dispose();
|
||||
_adapter?.Dispose();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MQTTnet.Exceptions;
|
||||
|
||||
namespace MQTTnet.Tests
|
||||
{
|
||||
@@ -16,6 +17,18 @@ namespace MQTTnet.Tests
|
||||
{
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(MqttCommunicationException))]
|
||||
public async Task Connect_To_Not_Existing_Server()
|
||||
{
|
||||
var client = new MqttFactory().CreateLowLevelMqttClient();
|
||||
var options = new MqttClientOptionsBuilder()
|
||||
.WithTcpServer("localhost")
|
||||
.Build();
|
||||
|
||||
await client.ConnectAsync(options, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Connect_And_Disconnect()
|
||||
{
|
||||
@@ -78,7 +91,7 @@ namespace MQTTnet.Tests
|
||||
|
||||
async Task<MqttConnAckPacket> Authenticate(ILowLevelMqttClient client)
|
||||
{
|
||||
await client.SendAsync(new MqttConnectPacket()
|
||||
await client.SendAsync(new MqttConnectPacket
|
||||
{
|
||||
CleanSession = true,
|
||||
ClientId = TestContext.TestName,
|
||||
|
||||
Reference in New Issue
Block a user