3

As per https://datatracker.ietf.org/doc/rfc6120/?include_text=1 and 10.1. In-Order Processing How is Ordered Message Delivery ensured across all items in roster?

  1. Is it done at server or client side? If it is on any side, are newer messages being waited upon older messages with a timeout?
  2. Does it use an incremental sequence number for ordering guarantees?
  3. On client re-connect, how does client know what to pull from server? Does the client send last msgIds of all items in roster? or does Server keep the QOS data and client state for each device ?
legoscia
  • 39,593
  • 22
  • 116
  • 167
sokc
  • 51
  • 2

1 Answers1

1

First of all, As XMPP uses TCP transport protocol it ensures the server receives the data in the same order the client sends it.

As per TCP docs:

TCP guarantees delivery of data and also guarantees that packets will be delivered in the same order in which they were sent

ejabbred is an XMPP server, the raw data received over the TCP must be compliant with the XMPP protocol and the same being verified XMPP server.

In XMPP protocol client can able to send messages after it has done with session initiation, resource bind, and authentication, etc..

These messages are being processed in the order the client sends it and routes to its recipients. If recipients are offline it push and pop to database the same order for later delivery.

Here ordering guarantees mostly ensure by the TCP network stack.

  • Yes Adinarayana, I understand that.I agree with you. But my question was to ensure the ordering of messages. Does the client use timestamps as the order identifier to send to server when it re-connects? If it does so, how does so server manage that? Because order cannot be derived from timestamps unlike an incremental ever increasing sequence. Even if it is incremental, how does server ensure ordering in case of failures? as in one of the messages drops? Would the server buffer the succeeding messages until the correct one arrives? – sokc Jun 29 '20 at 13:44
  • @sokc Are you referring to https://xmpp.org/extensions/xep-0198.html? Why message drops happen when you have reliable TCP connections underneath? Does message means stanza in XMPP (single chat) ? or it could be any stanza? ejabbered expect some order in receiving stanza during stream establishment. once stream got established it process the stanzas in the order it receives. each connection is associated with the erlang process which has a mailbox that places the receiving stanzas in a queue for processing. – Adinarayana Immidisetti Jun 29 '20 at 19:57
  • Hi Adinarayana, I believe i was unable to frame my question well last time. If we have multiple new and almost parallel(yet sequential) message requests to server, there's a possibility of pushing those messages to the mailbox in wrong order? Also, a possibility is if we want to asynchronously add these messages to mailboxes by pushing to a queue and consuming from it, we can lose order and it's hard to maintain given the distributed system and scale? Also, how does XMPP Client pull latest messages from Server after coming online, assuming 100 msgs are exchanged across 10 roster items? – sokc Jul 13 '20 at 12:55
  • As far as I know, ejabberd does not check the order of messages. It is something highly unlikely to get the messages in the wrong order. as each client having own set of process that processes the message one after another from TCP. and coming to your question "how does XMPP Client pull the latest messages from Server after coming online?" Do you mean offline messages?. Need not to pull server sends the offline message once the client hits presence online. based on the timestamps associated with message stanzas it may require to rearrange and before presenting it to UI. – Adinarayana Immidisetti Jul 14 '20 at 17:37
  • Maybe I am still unclear about your question. You said, "If we have multiple new and almost parallel(yet sequential) message requests to the server, there's a possibility of pushing those messages to the mailbox in the wrong order". which I did not understand at all. – Adinarayana Immidisetti Jul 14 '20 at 17:38
  • Hi Adinarayana, Assume Adam and Eve are Adi's contacts. Both Adam and Eve can send messages to Adi. And the messages are sent to Adi this way 1. Adam: m1 2. Eve: m2 3. Adam: m3 and server can get messages in this order 1. Adam: m1 2. Adam: m3 3. Eve: m2 But, Adi is offline and when Adi comes online, XMPP Server needs to push m1, m2, m3 to Adi's Device. So does ejabbered store what all messages are sent to each roster item? to figure out which are new messages? and since m1, m3 reached servers first, XMPP Server will push m1 and m3. But m2 happened before m3 – sokc Jul 15 '20 at 19:17
  • Does it really matter if m3 comes before m2 (each is sent by different sender) and I feel it perfectly fine and both nowhere related? XMPP is a protocol that takes care of Sender -->XMPP-Server--> Receiver. Do you see any specification that describes Sender1 and Sender2 and their messaging order w.r.t each other? Even you mentioned "In-Order Processing" describes a single client and server. Ejabbered delivers the message in the order they received. – Adinarayana Immidisetti Jul 15 '20 at 20:03
  • But if you still looking for functionality as such that, make sure the client sends another message only after it receives an acknowledgment for previous message from the server. Don't forget ejabbed is like a soft real-time system, not a hard one. – Adinarayana Immidisetti Jul 15 '20 at 20:08