[Standards] BOSH patches
lancestout at gmail.com
Tue Dec 10 22:36:56 UTC 2013
> In the 1.11 version I don't really understand the diagram under point 4. Too many "empty" bodies.
> - What is the left side and the right side?
> - From "X" to "*" is one HTTP request? Then why is there a long time no request (but many pipes |)?
We may need to include some more labeling information in the diagram itself then :) The pipes on each side only indicate the passage of time when the connection is not being used.
So, here’s the story that accompanies that diagram (from top down):
You have an active BOSH session going, with a single active connection. You have been POSTing BOSH requests over that connection, but there hasn’t been any new traffic to deliver, so the requests time out with empty responses. A new POST is made using that same connection after each timeout to continue listening for traffic.
Then, you have a message to send out. You open a second connection and POST your message. The pending POST you had on the other connection is then responded to (before its usual timeout) with an empty payload because there’s nothing to deliver.
Meanwhile, the POST that you used to send your message sticks around, waiting for any new traffic to be delivered, but it eventually times out, and returns with an empty result, and a new POST is made using that connection (since that’s the current ‘active’ connection).
Now, you want to send another message, so you flip the original connection back to ‘active’ and use it to send the POST for your message. The old pending POST on the other connection then returns. You then receive a message, which is delivered to your request on the ‘active’ connection (left side). You then send out a new POST to continue listening for traffic.
Once again, you want to send a message out, so you flip the ‘active’ connection over again (now on the right side). This time, you happened to have an incoming message at the same time, so it is delivered immediately as the response to your old pending POST (left side).
And then we time out again, and send a new request on the still ‘active’ right hand side connection.
The moral of the story is that you really only ever need two connections, and you flip between the two whenever you need to send a stanza and the old connection is sent whatever traffic has been buffered.
Hope that helps with implementing your Java BOSH client :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the Standards