kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

I get an exception. System.ArgumentException: An item with the same key has already been added. Key: Date #173

Open MakcStudio opened 4 years ago

MakcStudio commented 4 years ago

Hi. I use the library and get this exception sometimes. Is there any way to fix this?

2020-05-28 18:00:51.3025 WaxpeerApp.Program.CurrentDomain_UnhandledException Fatal: CurrentDomain_UnhandledException - CrashProgramm -> System.ArgumentException: An item with the same key has already been added. Key: Date
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at WebSocket4Net.Extensions.ParseMimeHeader(String source, IDictionary`2 valueContainer, String& verbLine)
   at WebSocket4Net.Protocol.DraftHybi10Processor.VerifyHandshake(WebSocket websocket, WebSocketCommandInfo handshakeInfo, String& description)
   at WebSocket4Net.Command.Handshake.ExecuteCommand(WebSocket session, WebSocketCommandInfo commandInfo)
   at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length)
   at WebSocket4Net.WebSocket.client_DataReceived(Object sender, DataEventArgs e)
   at SuperSocket.ClientEngine.ClientSession.OnDataReceived(Byte[] data, Int32 offset, Int32 length)
   at SuperSocket.ClientEngine.AuthenticatedStreamTcpSession.ReadAsync()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() 

<>c.<ThrowAsync>b__139_1 => ExceptionDispatchInfo.Throw => Program.CurrentDomain_UnhandledException
MakcStudio commented 4 years ago

image

I use it like this. Is this possible because of async void ?