diff --git a/e2e/test/iothub/service/ServiceClientE2ETests.cs b/e2e/test/iothub/service/ServiceClientE2ETests.cs index 33a14bc099..578607dd72 100644 --- a/e2e/test/iothub/service/ServiceClientE2ETests.cs +++ b/e2e/test/iothub/service/ServiceClientE2ETests.cs @@ -3,7 +3,6 @@ using System; using System.Diagnostics; -using System.Diagnostics.Tracing; using System.Text; using System.Threading.Tasks; using FluentAssertions; @@ -87,6 +86,20 @@ public async Task ServiceClient_SendsMessage(TransportType transportType) await sender.SendAsync(testDevice.Id, message).ConfigureAwait(false); } + [TestMethod] + [Timeout(TestTimeoutMilliseconds)] + [DataRow(TransportType.Amqp)] + [DataRow(TransportType.Amqp_WebSocket_Only)] + public async Task ServiceClient_Open(TransportType transportType) + { + // arrange + using TestDevice testDevice = await TestDevice.GetTestDeviceAsync(DevicePrefix).ConfigureAwait(false); + using var client = ServiceClient.CreateFromConnectionString(TestConfiguration.IotHub.ConnectionString, transportType); + + // act and expect no exception + await client.OpenAsync().ConfigureAwait(false); + } + // Unfortunately, the way AmqpServiceClient is implemented, it makes mocking the required amqp types difficult // (the amqp types are private members of the class, and cannot be set from any public/ internal API). // For this reason the following test is tested in the E2E flow, even though this is a unit test scenario. diff --git a/iothub/service/src/Messaging/ServiceClient.cs b/iothub/service/src/Messaging/ServiceClient.cs index 71d1c59892..5a800abed6 100644 --- a/iothub/service/src/Messaging/ServiceClient.cs +++ b/iothub/service/src/Messaging/ServiceClient.cs @@ -10,7 +10,6 @@ using Microsoft.Azure.Amqp; using Microsoft.Azure.Amqp.Framing; using Microsoft.Azure.Devices.Common; -using Microsoft.Azure.Devices.Common.Data; using Microsoft.Azure.Devices.Common.Exceptions; using Microsoft.Azure.Devices.Shared; @@ -290,9 +289,7 @@ public virtual async Task OpenAsync() if (Logging.IsEnabled) Logging.Enter(this, $"Opening AmqpServiceClient", nameof(OpenAsync)); - using var ctx = new CancellationTokenSource(_openTimeout); - - await _faultTolerantSendingLink.OpenAsync(ctx.Token).ConfigureAwait(false); + await _faultTolerantSendingLink.OpenAsync(_openTimeout).ConfigureAwait(false); await _feedbackReceiver.OpenAsync().ConfigureAwait(false); if (Logging.IsEnabled)