Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
rgcooper #1
Member since Jan 2012 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: XMPP Presence update when closing client over BOSH
Hi,

I'm noticing that when using the MatriX XMPP client over BOSH, the unavailable presence update that is meant to be sent from the MatriX client when the Close method is called doesn't always occur. I used Fiddler to trace the output and what I noticed was that in the cases where it worked fine, the Fiddler trace has something along the lines of:

  1. <body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="987513757" key="636c48127d2539bbfc3d1772b63f299e21efaca8" sid="e3ed05a7" to="lbg.arena" type="terminate" xmlns="http://jabber.org/protocol/httpbind" />

But in cases where it didn't work, the OnClose event callback wasn't fired (which I use to hook-up the application shutdown) and the Fiddler output did not contain any <type="terminate">. I've checked with our clients and their server team, and Openfire does not receive any of the terminate events either.

I've tried extending the time I wait for the OnClose event to fire before shutting the application down, but this doesn't seem to help. I can confirm that we are calling the Close method on the XmppClient.

What should be the correct way to close a Silverlight client and ensure the XMPP API has chance to tear-down, flush any queues and send any messages?

Cheers,
Rob
This post was edited on 2013-03-08, 20:52 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rgcooper:
I'm noticing that when using the MatriX XMPP client over BOSH, the unavailable presence update that is meant to be sent from the MatriX client when the Close method is called doesn't always occur. I used Fiddler to trace the output and what I noticed was that in the cases where it worked fine, the Fiddler trace has something along the lines of:

MatriX does not send the unavailable presence when the session gets Closed. It closes only the XMPP stream. When the XMPP stream gets closed then the server must notify all the contacts with a unavailable presence.
For sockets it send the stream footer </stream:stream>, and on bosh a HTTP request with the type terminate in the body.

Quote by rgcooper:
  1. <body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="987513757" key="636c48127d2539bbfc3d1772b63f299e21efaca8" sid="e3ed05a7" to="lbg.arena" type="terminate" xmlns="http://jabber.org/protocol/httpbind" />

But in cases where it didn't work, the OnClose event callback wasn't fired (which I use to hook-up the application shutdown) and the Fiddler output did not contain any <type="terminate">. I've checked with our clients and their server team, and Openfire does not receive any of the terminate events either.

Can you try to get the full HTTP trace of teh complete session with HTTP headers when possible?

Quote by rgcooper:
What should be the correct way to close a Silverlight client and ensure the XMPP API has chance to tear-down, flush any queues and send any messages?

what you re doing is correct. We have to find the reason why MatriX is not able to send the terminate or why the server does not get it.

  • Are you using the latest binary build?
  • Can you try to send a presence of type unavailable before the Close()?

  1. xmppClient.SendUnavailablePresence();
  2. xmppClient.Close();

Alex
This post was edited on 2013-03-08, 20:52 by Alex.
Avatar
rgcooper #3
Member since Jan 2012 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex, I think I know what the problem is: The terminate request is sometimes sent, but it doesn't have the cookies that are required by our IIS proxy server:

  1. <body xmlns:xmpp="urn:xmpp:xbosh" xmlns:stream="http://etherx.jabber.org/streams" rid="1432116272" key="0f57dfb358a52ef9a3a32c4b29620c5c1f5852a5" sid="bc8ec463" to="lbg.arena" type="terminate" xmlns="http://jabber.org/protocol/httpbind" />

HTTP/1.1 400 Username and/or token not provided
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 09 Jan 2012 17:20:48 GMT
Content-Length: 11

Bad Request
-----------------------------------------------------------------

Also, in our code, the handler for the create web request was throwing an exception which I think may have caused the MatriX code to fail to send the request??

However, the problem remains that when we tear the application down, the MatriX will sometimes tear down after our application code has started to tear down and when it tries to call back in to our code to get the cookies, it can't and so you get the above scenario.

Ideally, we could do with a default cookie container that we give you when setting up the client. When sending any request, it uses the default container if there is one, or can be overriden in the handler.

Cheers,
Rob
This post was edited on 2013-03-08, 20:53 by Alex.
Avatar
rgcooper #4
Member since Jan 2012 · 8 posts
Group memberships: Members
Show profile · Link to this post
I did try and send an unavailable presence before calling Close, and this does seem to work, but ideally I want to be in a situation where our terminate messages correctly fire to the server.
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
what is the exception you get?
Can you describe the problem more in detail?

What we have seen before is that Openfire does not free open webrequests when the session is terminated. Can you try to debug this with Fiddler? When the session gets terminated then the server must close and return all open requests.

Alex
Avatar
rgcooper #6
Member since Jan 2012 · 8 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

I've been investigating this a lot more, and I think I've found the problem in our code - it's an inter-play between the MatriX API and other HTTP APIs we're using in our application, but I think I can get the above scenario of SendUnavailablePresence followed by Close to work as expected now.

The problem arises when closing our application and the state of the UI thread when disposing and cleaning up objects. It's difficult to say more at this stage because we don't have an NDA in place, but an option would be for us to purchase the source code so we can investigate the issues ourselves. We already have licenses for the binaries, in principle - would it be possible to upgrade to software license if we could get the funding?

Rob
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rgcooper:
I've been investigating this a lot more, and I think I've found the problem in our code - it's an inter-play between the MatriX API and other HTTP APIs we're using in our application, but I think I can get the above scenario of SendUnavailablePresence followed by Close to work as expected now.

Do you use Browser HTTP or Client-HTTP? This can be also a problem because of the 2 request limit. BOSH always must be able to open  2 simultaneous requests.

Quote by rgcooper:
The problem arises when closing our application and the state of the UI thread when disposing and cleaning up objects. It's difficult to say more at this stage because we don't have an NDA in place, but an option would be for us to purchase the source code so we can investigate the issues ourselves. We already have licenses for the binaries, in principle - would it be possible to upgrade to software license if we could get the funding?

Feel free to contact me directly by email.

Alex
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: