Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
choquito #1
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Subject: BOSH connection problem
Hi, this is my first post, so greetings to all!!!

I'm using the last version of .NET Matrix.

We have a Tigase Server that works fine with bosh connection from IM clients like InstanBird or other mobile apps, but when I execute next function, the connection closed after 10 seconds approx.


  1. private void Connect()
  2. {
  3.     xmppClient.SetUsername(_cue_ID.ToString());
  4.     xmppClient.SetXmppDomain("im.xxxxx.com");
  5.     xmppClient.Password = "pass";
  6.     xmppClient.Status = "Ready";
  7.     xmppClient.Transport = Matrix.Net.Transport.BOSH;
  8.     xmppClient.Uri = new System.Uri("http://im.xxxxx.com:5280");
  9.     xmppClient.Show = Matrix.Xmpp.Show.chat;
  10.     xmppClient.StartTls = false;
  11.     xmppClient.KeepAliveInterval = 60;
  12.     xmppClient.AutoReplyToPing = true;
  13.     xmppClient.Open();
  14. }

If I don´t use bosh, the connection haven't any problem, works fine.

Events from init to end connection:

OnLogin
OnBind
OnIq
OnIq
OnRosterItem xxxxxx
OnRosterItem xxxxxx
OnRosterItem xxxxxx
OnRosterEnd
OnIq
OnPresence xxxxx
OnError
OnClose
OnError


XML Log:


  1. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="im.xxxxxx.com" version="1.0" >
  2. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="im.xxxxxx.com" version="1.0" id="af790ae1-0f37-4972-95ff-d57eb385ad26" >
  3. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
  4.  <ver xmlns="urn:xmpp:features:rosterver" />
  5.  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
  6.  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  7.     <mechanism>PLAIN</mechanism>
  8.     <mechanism>ANONYMOUS</mechanism>
  9.  </mechanisms>
  10.  <register xmlns="http://jabber.org/features/iq-register" />
  11.  <auth xmlns="http://jabber.org/features/iq-auth" />
  12. </stream:features>
  13. SEND: <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">ADEwMDAwMDA0AFIzZ2lzdHIw</auth>
  14. RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
  15. SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="im.xxxxxx.com" version="1.0" >
  16. RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="im.xxxxxx.com" version="1.0" id="af790ae1-0f37-4972-95ff-d57eb385ad26" >
  17. RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
  18.  <ver xmlns="urn:xmpp:features:rosterver" />
  19.  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
  20.  <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
  21.  <register xmlns="http://jabber.org/features/iq-register" />
  22.  <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" />
  23. </stream:features>
  24. SEND: <iq id="MX_1" type="set" xmlns="jabber:client">
  25.  <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  26.     <resource>MatriX</resource>
  27.  </bind>
  28. </iq>
  29. RECV: <iq type="result" xmlns="jabber:client" id="MX_1" to="10000004@im.xxxxxx.com/MatriX">
  30.  <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  31.     <jid>10000004@im.xxxxxx.com/MatriX</jid>
  32.  </bind>
  33. </iq>
  34. SEND: <iq id="MX_2" type="set" xmlns="jabber:client">
  35.  <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
  36. </iq>
  37. RECV: <iq type="result" xmlns="jabber:client" id="MX_2" to="10000004@im.xxxxxx.com/MatriX" />
  38. SEND: <iq id="MX_3" type="get" xmlns="jabber:client">
  39.  <query xmlns="jabber:iq:roster" />
  40. </iq>
  41. RECV: <iq type="result" xmlns="jabber:client" id="MX_3" to="10000004@im.xxxxxx.com/MatriX">
  42.  <query xmlns="jabber:iq:roster">
  43.     <item jid="almacen@im.xxxxxx.com" subscription="none" ask="subscribe" name="" />
  44.     <item jid="santipg@im.xxxxxx.com" subscription="from" name="santipg" />
  45.     <item jid="uno@im.xxxxxx.com" subscription="from" name="uno" />
  46.  </query>
  47. </iq>
  48. SEND: <presence xmlns="jabber:client">
  49.  <show>chat</show
  50.  <status>Preparado para chatear</status>
  51.  <priority>0</priority>
  52. </presence>
  53. RECV: <presence xmlns="jabber:client" from="10000004@im.xxxxxx.com/MatriX" to="10000004@im.xxxxxx.com">
  54.  <show>chat</show>
  55.  <status>Preparado para chatear</status>
  56.  <priority>0</priority>
  57. </presence>
  58. SEND: </stream:stream>



What is wrong in my source code?...

Thank you in advance for your time.
This post was edited 2 times, last on 2013-03-12, 00:50 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I see no errors in the Xml log. What is the exception in the OnError event?
BOSH log from OnSendBody and OnReceiveBody will help as well.

Alex
Avatar
choquito #3
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Hi Alex,

Screen captures from visual studio:


http://img441.imageshack.us/img441/5305/matrixexception.png

OnSendBody:
http://imageshack.us/a/img62/9877/xmppclientonsendbody.png

OnReceiveBody:
http://imageshack.us/a/img526/5554/xmppclientonreceivebody…
Avatar
Alex #4
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Seems to be still the problem with Tigase and HTTP 1.1 Keep Alives.

Try the following code in OnCreateWebRequest:

  1. private void xmppClient_OnCreateWebRequest(object sender, Matrix.Net.WebRequestEventArgs e)
  2. {
  3.     ((HttpWebRequest) e.WebRequest).KeepAlive = false;
  4. }

if it does not help then you should contact the Tigase developers, because MatriX does everything correct here.
Please let me know if this works. You can also try to set HTTP version to 1.0 in this event.

Alex
Avatar
choquito #5
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Alex,  with KeepAlive = false in OnCreateWebRequest.....does not work....

We set the http version to 1.0 and problem persists.

We are reviewing Tigase settings.
Avatar
Alex #6
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I suggest to contact the Tigase team. Because MatriX works fine with all other BOSH implementations we have tested.
Those are:

  • M-Link
  • Cisco XCP
  • ejabberd
  • Openfire
  • Prosody
  • Punjab
Avatar
choquito #7
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Hi Alex...however we have observed the following:

After the first OnPresence event (user presence stanza), OnPresence events for roster users not triggered
Finally, after a few seconds the connection is closed by server (timeout).

Events when don't works:

OnLogin
OnBind
OnIq
OnIq
OnRosterItem useraaaa
OnRosterItem userbbbb
OnRosterEnd
OnIq
OnPresence    user@xxxx.com/aaaa
(60 seconds......)
OnError
OnClose

Events when works fine:

OnLogin
OnBind
OnIq
OnIq
OnRosterItem useraaaa
OnRosterItem userbbbb
OnRosterEnd
OnIq
OnPresence    user@xxxx.com/aaaa
OnPresence    useraaaa@xxxx.com/test
OnPresence    userbbbb@xxxx.com/test

Thank you so much.
Avatar
kobit #8
Member since Mar 2013 · 1 post
Group memberships: Members
Show profile · Link to this post
It looks like inactivity timer fired up on the Tigase server. You did not show us any timings with your XML log and this could give us some hints. Inactivity timeout in Bosh means you have to establish a new Bosh connection within a specified period of time (10 secs by default) or the Bosh server "thinks" the client is no longer connected and destroys Bosh session.
Avatar
Alex #9
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Thanks Artur for your reply. I agree that it looks like the user gets kicked because of inactivity.

Here is a quote from XEP-0124:

Quote by XEP-0124:
10. Inactivity

After receiving a response from the connection manager, if none of the client's requests are still being held by the connection manager (and if the session is not a Polling Session), the client SHOULD make a new request as soon as possible. In any case, if no requests are being held, the client MUST make a new request before the maximum inactivity period has expired. The length of this period (in seconds) is specified by the 'inactivity' attribute in the session creation response.

MatriX always holds a request to the server. It always waits for the reply of the server. It never cancels or terminates a web request even when the request lives longer than the inactivity time defined.

My understanding of inactivity is that it only applies if no requests are held, and not the timespan between 2 requests.

@choquito
Please post the logs from OnReceiveBode and OnSendBody with timestamp, e.Body and e.WebRequestId.
As a workaround for now you can put a timer in your code now and send a Xmpp Ping packet in an interval which is a bit smaller than the Inactivity defined on your server. This should keep the connection alive.
Avatar
choquito #10
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Log from client (miniclient):
https://www.dropbox.com/s/2lwhdvfg76or5al/log_client.pdf

Log from tigase:
https://www.dropbox.com/s/tismcyjm1jkwc1v/log_server_tigas…

Thanks Alex. Artur, thanks to you too.
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