Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Lightbarrier #1
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Subject: Idle Out On Http Connection
Before I was using "AutoReplyToPing" through a regular socket connection and setting it to false so that when my server(in this case Openfire) idle time ran out the connection was closed.

However, with bosh I can't get the connection to close. I realize from the link below that "AutoReplyToPing" won't work with bosh however, I'm having the opposite results then the other user had.

http://forum.ag-software.net/thread/1173-Application-hangs…


By default Openfire is set up with a 30 second idle time for bosh, so I would think that Openfire would be closing the connection if the above link is true. However, from the end of the text file where I print out "OnSendXml" and "OnReceiveXml"  it looks as if Matrix is pinging the server after connecting even though the xml for each ping is "".

To verify this I decided to pause my application during the next "OnSendXml" and let a minute pass I then resumed the program and a couple errors were thrown, but the application logged out as if by timing out normally since it didn't ping Openfire.

So my question is that if I'm correct with Matrix and Bosh keeping the connection alive, do you have a good suggestion for changing this so the connection can idle out?
The author has attached one file to this post:
AutoPingHttpBinding.txt 3.4 kBytes
You have no permission to open this file.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
When you want to close the connection then execute the Close method.
AutoReplyToPing also works on Bosh. All it does is sending a reply when the server is pinging you. I don't know if the OpenFire server sends pings.
see also: http://xmpp.org/extensions/xep-0199.html

Why do you wan to close an idle connection? The idea of XMPP is having a long living connection, to be able to send and receive data in realtime at any time.

The 30 seconds in you server setup is probably the inactive time. Sockets are using a persistent socket connection. When your network gets disconnected then the socket breaks and your XMPP gets closed.
Bosh is using HTTP as transport, which is not a persistent connection, so a network interruption cannot be detected. For this reason there is the inactive value which sais:
When I don't see a new HTTP request from a client after its last request for XX seconds then close the XMPP connection.

Alex
Avatar
Lightbarrier #3
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Thanks for your help.

Besides for giving the user control over when they close the connection, for some of our users we want their connection to time out as they'll be waiting for someone to start a chat with them, and in the case where no one initiates a conversation with them it's better for them to timeout then for them to sit there waiting on the server forever. 

That being said, it seems that a socket connection is more reliable on xmpp however, we can't have our users using a socket connection it's http or nothing.

Through Openfire there are properties to set wither the Server pings the user or not(xmpp.client.idle.ping) which we have working on a socket connection however, the behavior exhibited on a http connection shows that Openfire doesn't ping the connection yet the connection stays alive. From my earlier document it does appear like Matrix is pining Openfire though after establishing the connection.

Also, what do you mean by inactive value sais?

By your last statement are you saying it's best to have a timer on the application using Matrix, and that once it times out the connection will automatically be closed? I'm trying to avoid this situation as much as possible however, if there's no other solution with Bosh then I'll have to implement it.
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
as I said before the inative value of Bosh means:

When the server does not get a new request from the client for XX seconds after all requests are closed it ends the XMPP connection.
BOSH only work when a BOSH client always has an active connection. So MatriX tries to keep always once connection active.
This is why it does not work, and cannot work. The inactive value can only trigger when the network between your client and the server is down for X seconds.

What you are doing is wrong. Keep alives, pings and inactive values are developed to keep connection alive, and not to kill them.
Why are you hot putting a timer in our app when you can to close the connection? And then execute the close command in your software when you think its appropriate to call it.

Having idle connection does not hurt in XMPP, this technology was developed for long living connections.
Avatar
Lightbarrier #5
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Thanks for the help Alex.

For the record I haven't implemented the timer yet.

In regards to why we would want something like a timer that closes the connection from the users control, like I said before there is a necessary functionality where the user can't always close the connection, this doesn't mean that the user has to idle out however, it's a functionality that has to be created one way or another. I don't write my own functionality requirements, I just try to design and code them to the best of my ability, unless they would somehow break something that's another issue which I would consult with my superiors about.

Part of this has to do with the fact that we have two types of users. There are users that need that long lasting connection who will always disconnect manually. Then there are users who well come on for short periods of time, who may get disconnected if a user they're waiting to talk to is taking to long.

If the Matrix library is doing its best to keep the bosh connection alive(which makes since trust me), and there is nothing that can be done on the servers side. I see little choice but to create an optional variable which when set will keep track of the time when the last request was sent/received, and upon the app doing a update or check of the latest time it will be compared to see if the connection needs to be closed or not.

You make it sound like there's really no solution for this, but I'm sorry this has to be implemented one way or another, if you have anything else you would add to this then please do otherwise I see little choice but to go ahead and implement this. 

Thanks again for the help.
Avatar
Alex #6
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
as I said, this is the how Bosh is designed. This is nor a problem of MatriX, and not a problem of XMPP,
Please read more about BOSH here:
http://xmpp.org/extensions/xep-0124.html

you have to solve this with a timer in your app and then call Close. Anything else makes no sense and is wrong designed.

Alex
Avatar
Lightbarrier #7
Member since Jul 2014 · 52 posts
Group memberships: Members
Show profile · Link to this post
Okay Alex we'll implement the timer, thanks for your help.
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