DotNetty icon indicating copy to clipboard operation
DotNetty copied to clipboard

channel.WriteAsync hangs forever if channel is closed

Open ewertons opened this issue 5 years ago • 0 comments

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.

ewertons avatar Jul 17 '19 22:07 ewertons