public async Task <AmqpIoTConnection> OpenConnectionAsync(TimeSpan timeout)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, timeout, $"{nameof(OpenConnectionAsync)}");
            }

            var amqpSettings          = new AmqpSettings();
            var amqpTransportProvider = new AmqpTransportProvider();

            amqpTransportProvider.Versions.Add(s_amqpVersion_1_0_0);
            amqpSettings.TransportProviders.Add(amqpTransportProvider);

            var amqpConnectionSettings = new AmqpConnectionSettings()
            {
                MaxFrameSize = AmqpConstants.DefaultMaxFrameSize,
                ContainerId  = CommonResources.GetNewStringGuid(),
                HostName     = _hostName
            };

            TimeSpan idleTimeout = _amqpTransportSettings.IdleTimeout;

            if (idleTimeout != null)
            {
                amqpConnectionSettings.IdleTimeOut = Convert.ToUInt32(idleTimeout.TotalMilliseconds);
            }

            var amqpIoTTransport = new AmqpIoTTransport(amqpSettings, _amqpTransportSettings, _hostName, s_disableServerCertificateValidation);

            TransportBase transportBase = await amqpIoTTransport.InitializeAsync(timeout).ConfigureAwait(false);

            try
            {
                var amqpConnection = new AmqpConnection(transportBase, amqpSettings, amqpConnectionSettings);
                AmqpIoTConnection amqpIoTConnection = new AmqpIoTConnection(amqpConnection);
                amqpConnection.Closed += amqpIoTConnection.AmqpConnectionClosed;
                await amqpConnection.OpenAsync(timeout).ConfigureAwait(false);

                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, timeout, $"{nameof(OpenConnectionAsync)}");
                }

                return(amqpIoTConnection);
            }
            catch (Exception e) when(!e.IsFatal())
            {
                transportBase?.Close();
                throw;
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, $"{nameof(OpenConnectionAsync)}");
                }
            }
        }
 public void Dispose()
 {
     _amqpIotTransport?.Dispose();
     _amqpIotTransport = null;
 }