Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
PTEC3D70 #1
Member since Dec 2013 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Reconnect sample problem
Hello,

I have modified the reconnect sample to run 10 client in parallel.

The problem is that sometime some clients are looping on the reconnect timer when the first connection failed.

With the output i can see that the problem comes from an OnError event (ClientSocket Connection request failed)
1 second after the client who received the onError event receives an OnLoggin and an OnBind event.
5 second after the reconnect timer fires an try to open an already opened client. It fails and relanch a 5s timer to reconnect.

What is the best method to resolve this issue ?

The output of the program :

16:24:12 : 0 : connect: XMPP connecting....
16:24:12 : 1 : connect: XMPP connecting....
16:24:12 : 2 : connect: XMPP connecting....
16:24:12 : 3 : connect: XMPP connecting....
16:24:12 : 4 : connect: XMPP connecting....
16:24:12 : 5 : connect: XMPP connecting....
16:24:12 : 6 : connect: XMPP connecting....
16:24:12 : 7 : connect: XMPP connecting....
16:24:12 : 8 : connect: XMPP connecting....
16:24:12 : 9 : connect: XMPP connecting....
press any key to stop
16:24:12 : 5 : OnError: ClientSocket Connection request failed.
16:24:12 : 5 : starting reconnect timer...
16:24:12 : 8 : OnError: ClientSocket Connection request failed.
16:24:12 : 8 : starting reconnect timer...
16:24:12 : 9 : OnError: ClientSocket Connection request failed.
16:24:12 : 9 : starting reconnect timer...
16:24:13 : 6 : OnLogin
16:24:13 : 2 : OnLogin
16:24:13 : 0 : OnLogin
16:24:13 : 6 : OnBind: XMPP connected. JID: jabber01@e-i.net/other6 :
16:24:13 : 2 : OnBind: XMPP connected. JID: jabber01@e-i.net/other2 :
16:24:13 : 5 : OnLogin
16:24:13 : 0 : OnBind: XMPP connected. JID: jabber01@e-i.net/other0 :
16:24:13 : 7 : OnLogin
16:24:13 : 5 : OnBind: XMPP connected. JID: jabber01@e-i.net/other5 :
16:24:13 : 9 : OnLogin
16:24:13 : 7 : OnBind: XMPP connected. JID: jabber01@e-i.net/other7 :
16:24:13 : 4 : OnLogin
16:24:13 : 1 : OnLogin
16:24:13 : 3 : OnLogin
16:24:13 : 9 : OnBind: XMPP connected. JID: jabber01@e-i.net/other9 :
16:24:13 : 4 : OnBind: XMPP connected. JID: jabber01@e-i.net/other4 :
16:24:13 : 8 : OnLogin
16:24:13 : 3 : OnBind: XMPP connected. JID: jabber01@e-i.net/other3 :
16:24:14 : 1 : OnBind: XMPP connected. JID: jabber01@e-i.net/other1 :
16:24:14 : 8 : OnBind: XMPP connected. JID: jabber01@e-i.net/other8 :
16:24:17 : 5 : connect: XMPP connecting....
16:24:17 : 5 : OnError: The Open method cannot be called on an active stream.
16:24:17 : 5 : starting reconnect timer...
16:24:17 : 8 : connect: XMPP connecting....
16:24:17 : 8 : OnError: The Open method cannot be called on an active stream.
16:24:17 : 8 : starting reconnect timer...
16:24:17 : 9 : connect: XMPP connecting....
16:24:17 : 9 : OnError: The Open method cannot be called on an active stream.
16:24:17 : 9 : starting reconnect timer...
16:24:22 : 5 : connect: XMPP connecting....
16:24:22 : 5 : OnError: The Open method cannot be called on an active stream.
16:24:22 : 5 : starting reconnect timer...
16:24:22 : 8 : connect: XMPP connecting....
16:24:22 : 8 : OnError: The Open method cannot be called on an active stream.
16:24:22 : 8 : starting reconnect timer...
16:24:22 : 9 : connect: XMPP connecting....
16:24:22 : 9 : OnError: The Open method cannot be called on an active stream.
16:24:22 : 9 : starting reconnect timer...

I have joined the two modified files from the reconnect sample (ReconnectXmppWrapper.cs, Program.cs).

Thanks.
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by PTEC3D70:
I have joined the two modified files from the reconnect sample (ReconnectXmppWrapper.cs, Program.cs).

I see no attachment.

I have extracted client 5 only from your log and added comments.

16:24:12 : 5 : connect: XMPP connecting....
16:24:12 : 5 : OnError: ClientSocket Connection request failed.
// connection failes, you try a reconnect
16:24:12 : 5 : starting reconnect timer...
// OnLogin indicates that TCP connection inclusing the authentication succeeded
16:24:13 : 5 : OnLogin
// Bind is the next step after OnLogin, so everything still looks fine for this connction
16:24:13 : 5 : OnBind: XMPP connected. JID: jabber01@e-i.net/other5 :
// You are calling the Open method again on a XmppCLient which is already connected on in progress of connecting
16:24:17 : 5 : connect: XMPP connecting....
16:24:17 : 5 : OnError: The Open method cannot be called on an active stream.

The problem is that you are executing the Open method twice on the same XmppClient.

Alex
Avatar
PTEC3D70 #3
Member since Dec 2013 · 6 posts
Group memberships: Members
Show profile · Link to this post
Do you have the attachment now ?

I have added comments to yours :

16:24:12 : 5 : connect: XMPP connecting....
16:24:12 : 5 : OnError: ClientSocket Connection request failed.
// connection failes, you try a reconnect
=> in the sample the reconnect is launched 5s later with a timer
16:24:12 : 5 : starting reconnect timer...
// OnLogin indicates that TCP connection inclusing the authentication succeeded
16:24:13 : 5 : OnLogin
// Bind is the next step after OnLogin, so everything still looks fine for this connction
=> why do we received an OnError if all is fine ?
16:24:13 : 5 : OnBind: XMPP connected. JID: jabber01@e-i.net/other5 :
// You are calling the Open method again on a XmppCLient which is already connected on in progress of connecting
=> the timer expires and i agree we try to call open on an opened client ! the reconnect callback should test if the client is opened ? how ?
16:24:17 : 5 : connect: XMPP connecting....
16:24:17 : 5 : OnError: The Open method cannot be called on an active stream.
The author has attached one file to this post:
reconnect.7z 1.3 kBytes
You have no permission to open this file.
Avatar
Alex #4
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I can reproduce the problem now when trying to connect at least 20 clients at the same time to one of our servers.
The server has only a pool of concurrent connections which can be accepted. When it denies a connection request there seems to me a problem in the reconnect example.

I will debug this and hopefully come back to you soon with a solution.

Alex
Avatar
Alex #5
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I was able to cause your problem and have found a threading issue. This should be fixed now in build 1.5.4.7.
Can you please get it from and test it?
http://www.ag-software.net/download-directory/

Thanks,
Alex
Avatar
PTEC3D70 #6
Member since Dec 2013 · 6 posts
Group memberships: Members
Show profile · Link to this post
I have tested with the new version, and all is ok.

Thanks.
Avatar
Alex #7
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great, thanks for your confirmation.
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: