Not logged in. · Lost password · Register
Forum: MatriX RSS
humba #1
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
Subject: Dictionary key problem on reconnect
I recently saw this running through my console. I was running my APP that connects to Cisco CIMP using XMPP, and connectivity was lost because I was debugging. My app is written to reconnect if the server is still up, which is the case here (it's just that if I take too long proceeding in the debugger, the connection interrupts).

So, I got this stacktrace

15:39:55.246 Unable to connect to srvccx12.nxodev.intra: An item with the same key has already been added. Key: System.Func`2[Matrix.Xml.XmppXElement,System.Boolean] at    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 Matrix.Network.Handlers.XmppStanzaHandler.Handle(Func`2 predicate, Action`2 action)
   at Matrix.Network.Handlers.XmppStanzaHandler.SendAsync[T](Func`1 sendTask, Func`2 predicate, Int32 timeout, CancellationToken cancellationToken)
   at Matrix.Network.Handlers.XmppStanzaHandler.SendAsync[T1,T2](String s, Int32 timeout, CancellationToken cancellationToken)
   at Matrix.XmppConnection.SendAsync[T1,T2](String data, Int32 timeout, CancellationToken cancellationToken)
   at Matrix.XmppConnection.SendStreamHeaderAsync(Int32 timeout, CancellationToken cancellationToken)
   at Matrix.XmppConnection.SendStreamHeaderAsync(CancellationToken cancellationToken)
   at Matrix.XmppClient.ConnectAsync(CancellationToken cancellationToken)
   at Matrix.XmppClient.ConnectAsync()
   at CiscoXmppLib.XmppConnector.Login(Boolean retryOnError, Boolean aquireLock) in D:\Personal\Documents\Visual Studio 2012\Projects\CiscoFinesseTest\CiscoXmppLib\XmppConnector.cs:line 446

The last line is my code, a simple ConnectAsync

var connected = await xmppClient.ConnectAsync().ConfigureAwait(false);

I haven't looked at the Matrix code yet, but that shouldn't be happening, right?
Avatar
Alex #2
Member since Feb 2003 · 4438 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello humba,

I assume the issue is here:
https://github.com/matrix-xmpp/matrix-vnext/blob/9d7407d41…

Its possible that it is adding a handler twice. So not sure if it comes from your user code or the MatriX core code.
Maybe you can debug.

Also, the latest MatriX vNext codes are on the net5 branch. Because dotNetty which we used as the networking stack initially seems to be not in development anymore by Microsoft. Also the net5 branch is compatible with netcore 5 and will be merged to master very soon.

Alex
humba #3
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
I've only seen it once, but I will have to do some more redundancy testing shortly so I'll keep an eye out if it's something I can reproduce - and if so I can try with my own builds. I just figured maybe you had an idea as normally I run my builds with the github packages, not the self-built version.
Avatar
Alex #4
Member since Feb 2003 · 4438 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I was assuming that the new connection gets a new instance of this handler, and therefore a new dictionary.
If this is not the case then we may need to clear the dictionary on reconnect.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS