DotNetty
DotNetty copied to clipboard
channel.WriteAsync hangs forever if channel is closed
Azure IoT C# SDK uses DotNetty for MQTT. We found an issue where ReceiveAsync was hanging if DeviceClient.Dispose was called right after.
Looks like there is a race condition where if the ReceiveAsync task reaches channel.WriteAsync before the cleanup function (triggered by Dispose) gets to channel.CloseAsync, channel.WriteAsync hangs forever.
It would be expected that WriteAsync return if CloseAsync is called while it's running. Also, looking at the API there is no option to pass cancellation tokens or set timeouts for WriteAsync.