From cf947415e8c9b2e4bcd275642042ce030aaf5089 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Sat, 2 Jun 2018 11:54:22 +0200 Subject: [PATCH] enable abort exceptions --- .../MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Frameworks/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs b/Frameworks/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs index 40ba295..4bf74fb 100644 --- a/Frameworks/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs +++ b/Frameworks/MQTTnet.AspnetCore/Client/Tcp/TcpConnection.cs @@ -131,14 +131,14 @@ namespace MQTTnet.AspNetCore.Client.Tcp if (!_aborted) { // Calling Dispose after ReceiveAsync can cause an "InvalidArgument" error on *nix. - //error = new MqttCommunicationException(); + error = ConnectionAborted(); } } catch (ObjectDisposedException) { if (!_aborted) { - //error = new MqttCommunicationException(); + error = ConnectionAborted(); } } catch (IOException ex) @@ -153,7 +153,7 @@ namespace MQTTnet.AspNetCore.Client.Tcp { if (_aborted) { - //error = error ?? new MqttCommunicationException(); + error = error ?? ConnectionAborted(); } _application.Output.Complete(error); @@ -193,6 +193,11 @@ namespace MQTTnet.AspNetCore.Client.Tcp } } + private Exception ConnectionAborted() + { + return new MqttCommunicationException("Connection Aborted"); + } + private async Task DoSend() { Exception error = null;