Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
matianyi #1
Member since Mar 2012 · 19 posts · Location: Japan
Group memberships: Members
Show profile · Link to this post
Subject: BOSH:can i wait unit XmppClient sent unavailable presence to server then dispose it.
Matrix v1.5.2.8

I have some logic like this when the client is logouted by user.
  1. XmppClient.SendUnavailablePresence("logout");
  2. XmppClient.Close();
  3. XmppClient.Dispose();

I found that sometimes the XmppClient disposed before unavailable presence and terminate body is sent.
Is there anyway to wait unit the SendUnavailablePresence() and XmppClient.Close() is processed?
This post was edited on 2013-02-19, 11:33 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please post your BOSH logs with timestamps when this happens. Log from OnSendBody and OnReceiveBody.

Alex
Avatar
matianyi #3
Member since Mar 2012 · 19 posts · Location: Japan
Group memberships: Members
Show profile · Link to this post
Hi,Alex

i am sorry that reply so late.

the log is like this:

  1. OnSendBody:<body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="542294926" key="637db80e707b5014edc8f24bed8b7ef90801bf0d" sid="2c8f48a79cb348c9aabc511c111e219c" to="example.com" xmlns="http://jabber.org/protocol/httpbind">
  2.  <iq id="MX_356" type="get" xmlns="jabber:client">
  3.     <query xmlns="http://xmpp.legendapl.com/protocol/offlinemsg#summary" />
  4.  </iq>
  5.  <iq id="MX_357" from="user1@example.com/da21e75d02e1497cac924e3aa03e0546" type="set" xmlns="jabber:client">
  6.     <query xmlns="http://xmpp.legendapl.com/protocol/status">
  7.       <show>NONE</show>
  8.       <status>Online</status>
  9.     </query>
  10.  </iq>
  11. </body>
  12.  
  13. OnReceiveBody:<body xmlns="http://jabber.org/protocol/httpbind">
  14.  <iq xmlns="jabber:client" to="user1@example.com/da21e75d02e1497cac924e3aa03e0546" type="result" id="MX_357">
  15.     <query xmlns="http://xmpp.legendapl.com/protocol/status"></query>
  16.  </iq>
  17. </body>

user click logout button and we call XmppClient.Close() and XmppClient.Dispose() to end the session.
then show the login window.
the user click login button and we create a new instance of XmppClient.
  1. 2013-02-25 20:29:18,861 [BOSH sender thread] OnCreateWebRequest
  2. 2013-02-25 20:29:18,884 [1] OnSendBody:<body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="542294927" key="c6c557ec4ac7a4894960172bfd49b1190016f949" sid="2c8f48a79cb348c9aabc511c111e219c" to="example.com" xmlns="http://jabber.org/protocol/httpbind">
  3.  <presence type="unavailable" xmlns="jabber:client">
  4.     <status>?????</status>
  5.  </presence>
  6. </body>

The body that sends unavailable presence stanza should have a type attribute and value is "terminate", shouldn't it.
i found that it sometimes has a terminate, sometimes not.

here the new session is created but the old one is still alive.

  1. 2013-02-25 20:29:19,389 [1] OnCreateWebRequest
  2. 2013-02-25 20:29:19,413 [1] OnSendBody:<body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" ver="1.6" xmpp:version="1.0" hold="1" wait="300" rid="1969895846" polling="0" to="example.com" secure="true" newkey="a6291686254fc978df4e625706deef01f65afc1a" xmlns="http://jabber.org/protocol/httpbind" />
  3. 2013-02-25 20:29:19,491 [1] OnReceiveBody:<body xmlns="http://jabber.org/protocol/httpbind" wait="60" inactivity="60" polling="15" requests="2" hold="1" sid="c982f76f74354ee1ac39c5ea8f177abd" ver="1.6" from="example.com" secure="true" maxpause="120" ack="1969895846">
  4.  <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  5.     <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  6.       <mechanism>PLAIN</mechanism>
  7.     </mechanisms>
  8.     <register xmlns="http://jabber.org/features/iq-register"></register>
  9.  </stream:features>
  10. </body>
  11. 2013-02-25 20:29:19,890 [BOSH sender thread] OnCreateWebRequest
  12. 2013-02-25 20:29:19,915 [1] OnSendBody:<body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="1969895847" key="cd7b27cfef85c47b0b3b1486b668db58a2c088d3" sid="c982f76f74354ee1ac39c5ea8f177abd" to="example.com" xmlns="http://jabber.org/protocol/httpbind">
  13.  <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">AHVzZXIxADAwMDAwMA==</auth>
  14. </body>
  15. 2013-02-25 20:29:19,992 [1] OnReceiveBody:<body xmlns="http://jabber.org/protocol/httpbind">
  16.  <iq xmlns="jabber:client" from="user1@example.com" to="user1@example.com/da21e75d02e1497cac924e3aa03e0546" type="set" id="1361791759995">
  17.     <command xmlns="http://jabber.org/protocol/commands" action="execute" node="logout"></command>
  18.  </iq>
  19. </body>
  20. 2013-02-25 20:29:19,996 [1] OnReceiveBody:<body xmlns="http://jabber.org/protocol/httpbind">
  21.  <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></success>
  22. </body>
This post was edited on 2013-03-06, 08:18 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by matianyi:
user click logout button and we call XmppClient.Close() and XmppClient.Dispose() to end the session.
then show the login window.

you should never call Dispose. The Close() method is asynchronous as the Open() method is.
There is no Dispose in MatriX. The Dispose method is coming from the component base class which is needed to show up the XmppClient in the Toolbox.


Quote by matianyi:
The body that sends unavailable presence stanza should have a type attribute and value is "terminate", shouldn't it.
i found that it sometimes has a terminate, sometimes not.
no, this depends on the timing. When you send a unavailable presence then it gets processed by the sender thread. I cannot know if a Close call is coming some milliseconds later or not. When get get the Close before the packet was sent then terminate is added, otherwiese it gets send and new webrequest with the terminate attribute gets created.
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: