From 79d95c85161b812ce51776b30a989abaa4f036dd Mon Sep 17 00:00:00 2001 From: Gen Date: Mon, 13 Apr 2020 03:04:44 -0700 Subject: [PATCH] Fix hanging issue under UWP. --- Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs b/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs index cb0f71c..44af1fd 100644 --- a/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs +++ b/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs @@ -64,7 +64,8 @@ namespace MQTTnet.Implementations if (_options.TlsOptions?.UseTls != true) { - await _socket.ConnectAsync(new HostName(_options.Server), _options.GetPort().ToString()); + var asyncAction = _socket.ConnectAsync(new HostName(_options.Server), _options.GetPort().ToString()); + await asyncAction; } else { @@ -85,7 +86,8 @@ namespace MQTTnet.Implementations socketProtectionLevel = SocketProtectionLevel.Tls10; } - await _socket.ConnectAsync(new HostName(_options.Server), _options.GetPort().ToString(), socketProtectionLevel); + var asyncAction = _socket.ConnectAsync(new HostName(_options.Server), _options.GetPort().ToString(), socketProtectionLevel); + await asyncAction; } Endpoint = _socket.Information.RemoteAddress + ":" + _socket.Information.RemotePort;