You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the client in a Xamarin Forms project on an Android 8.0 device and about 70% of the time things run as expected. The other 30% of the times I launch the app it crashes immediately with an unhandled exception stating "An item with the same key has already been added. Key: System.Net.Mqtt.Sdk.Storage.RetainedMessage". I've tried try/catch on everything to do with the client object and it doesn't catch it.
The call stack is as following: at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException (System.Object key) [0x00006] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Collections.Generic.Dictionary'2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000ad] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Collections.Generic.Dictionary'2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Net.Mqtt.Sdk.Storage.InMemoryRepositoryProvider.GetRepository[T] () [0x0006a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Storage\InMemoryRepositoryProvider.cs:24 at System.Net.Mqtt.Sdk.Flows.ClientProtocolFlowProvider.InitializeFlows () [0x00012] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ClientProtocolFlowProvider.cs:21 at System.Net.Mqtt.Sdk.Flows.ProtocolFlowProvider.GetFlows () [0x00008] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ProtocolFlowProvider.cs:64 at System.Net.Mqtt.Sdk.Flows.ProtocolFlowProvider.GetFlow (System.Net.Mqtt.Sdk.Packets.MqttPacketType packetType) [0x0002a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ProtocolFlowProvider.cs:40 at System.Net.Mqtt.Sdk.ClientPacketListener+<DispatchPacketAsync>d__23.MoveNext () [0x0002a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\ClientPacketListener.cs:194 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Net.Mqtt.Sdk.ClientPacketListener+<<ListenNextPackets>b__17_0>d.MoveNext () [0x0002c] in C:\Code\Xamarin\mqtt\src\Client\Sdk\ClientPacketListener.cs:108 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
Cheers,
Elco
The text was updated successfully, but these errors were encountered:
- Without the concurrency control it could happen that the flows are initialized in parallel, causing a duplicate key exception on the flows dictionary to be thrown
- Yhis fixes GitHub Issue "Occasional Unhandled Exceptions #142": #142
- Without the concurrency control it could happen that the flows are initialized in parallel, causing a duplicate key exception on the flows dictionary to be thrown
- Yhis fixes GitHub Issue "Occasional Unhandled Exceptions #142": #142
I am using the client in a Xamarin Forms project on an Android 8.0 device and about 70% of the time things run as expected. The other 30% of the times I launch the app it crashes immediately with an unhandled exception stating
"An item with the same key has already been added. Key: System.Net.Mqtt.Sdk.Storage.RetainedMessage"
. I've tried try/catch on everything to do with the client object and it doesn't catch it.The call stack is as following:
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException (System.Object key) [0x00006] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Collections.Generic.Dictionary'2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000ad] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Collections.Generic.Dictionary'2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Net.Mqtt.Sdk.Storage.InMemoryRepositoryProvider.GetRepository[T] () [0x0006a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Storage\InMemoryRepositoryProvider.cs:24 at System.Net.Mqtt.Sdk.Flows.ClientProtocolFlowProvider.InitializeFlows () [0x00012] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ClientProtocolFlowProvider.cs:21 at System.Net.Mqtt.Sdk.Flows.ProtocolFlowProvider.GetFlows () [0x00008] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ProtocolFlowProvider.cs:64 at System.Net.Mqtt.Sdk.Flows.ProtocolFlowProvider.GetFlow (System.Net.Mqtt.Sdk.Packets.MqttPacketType packetType) [0x0002a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\Flows\ProtocolFlowProvider.cs:40 at System.Net.Mqtt.Sdk.ClientPacketListener+<DispatchPacketAsync>d__23.MoveNext () [0x0002a] in C:\Code\Xamarin\mqtt\src\Client\Sdk\ClientPacketListener.cs:194 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Net.Mqtt.Sdk.ClientPacketListener+<<ListenNextPackets>b__17_0>d.MoveNext () [0x0002c] in C:\Code\Xamarin\mqtt\src\Client\Sdk\ClientPacketListener.cs:108 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
Cheers,
Elco
The text was updated successfully, but these errors were encountered: