Skip to content

Commit

Permalink
WebSocketTransport CloseInternal returning incorrect status.
Browse files Browse the repository at this point in the history
  • Loading branch information
xinchen10 committed Sep 10, 2021
1 parent 2787c19 commit 3e3b7b1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Microsoft.Azure.Amqp/Amqp/Transport/WebSocketTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ protected override bool CloseInternal()
Task task = webSocket.CloseAsync(WebSocketCloseStatus.Empty, string.Empty, CancellationToken.None);
if (task.IsCompleted)
{
return false;
return true;
}

task.ContinueWith(t =>
{
Exception exception = t.IsFaulted ? t.Exception.InnerException : (t.IsCanceled ? new OperationCanceledException() : null);
this.CompleteClose(false, exception);
});
return true;

return false;
}

protected override void AbortInternal()
Expand Down
9 changes: 9 additions & 0 deletions test/TestAmqpBroker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Runtime.InteropServices;

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("BE4D50FC-A2FB-4CA3-9128-3B5E7AFAD30A")]
3 changes: 2 additions & 1 deletion test/TestAmqpBroker/TestAmqpBroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public TestAmqpBroker(IList<string> endpoints, string userInfo, string sslValue,
listeners[i] = tcpSettings.CreateListener();
}
#if !NETSTANDARD
else if (addressUri.Scheme.Equals("ws", StringComparison.OrdinalIgnoreCase))
else if (addressUri.Scheme.Equals("ws", StringComparison.OrdinalIgnoreCase) ||
addressUri.Scheme.Equals("wss", StringComparison.OrdinalIgnoreCase))
{
WebSocketTransportSettings wsSettings = new WebSocketTransportSettings() { Uri = addressUri };
listeners[i] = wsSettings.CreateListener();
Expand Down
4 changes: 0 additions & 4 deletions test/TestAmqpBroker/TestAmqpBroker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,5 @@
<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Azure.Amqp\Microsoft.Azure.Amqp.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

</Project>

0 comments on commit 3e3b7b1

Please sign in to comment.