Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
lampo #1
Member since May 2018 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Does the Matrix vNext implemented the XEP-0198?
Does the Matrix vNext implemented the XEP-0198? is there any example about it?
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Yes, it's implemented.
When you let me know at which features of Stream Management you are interested I can give you some guidance.
Avatar
lampo #3
Member since May 2018 · 6 posts
Group memberships: Members
Show profile · Link to this post
Thank you very much.

I making test program use matrix-vnext client connect to the tigase xmpp server, i came across a issue:
There are two clients, A and B, A send message to B within seconds of the network lost, the message will lost and A client did not get any exception, and B never get the message, and the client A do not know the message lost. 

And then i search on google, they say i should implement the XEP-0198 on client,  so i ask the question here. Thanks a lot if you can give me the guidance..
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes, Steam Management can help in this situation. But also extensions which are fully end to end like receipts. Or just using IQs, which are also end to end and always require a reply.

In Stream Management you have an acking scenario described here:
https://xmpp.org/extensions/xep-0198.html#scenarios-basic

Both, the server and the client arte counting outgoing and incoming packages. Then very light ack requests are used to request counters from each other. If they are not in sync then we know that we had package loss.
You could request an ack for every package which you send, which tells you whether a packet was successfully transmitted or not.

But be aware that Stream Management acks are not fully end to end. There can still something go wrong while delivering the stanza to the other end, or on the client while receiving the stanza. Here is the exact definition from XEP-0198:

Definition: Acknowledging a previously-received ack element indicates that the stanza(s) sent since then have been "handled" by the server. By "handled" we mean that the server has accepted responsibility for a stanza or stanzas (e.g., to process the stanza(s) directly, deliver the stanza(s) to a local entity such as another connected client on the same server, or route the stanza(s) to a remote entity at a different server); until a stanza has been affirmed as handled by the server, that stanza is the responsibility of the sender (e.g., to resend it or generate an error if it is never affirmed as handled by the server).

Receipt of an <r/> element does not imply that new stanzas have been transmitted by the peer; receipt of an <a/> element only indicates that new stanzas have been processed if the 'h' attribute has been incremented.

Here is a sample on how to enable Stream Management in MatriX:
  1. var xmppClient = new XmppClient(
  2.                 conf =>
  3.                 {
  4.                     conf.UseAutoReconnect();
  5.                     conf.UseStreamManagement();
  6.                 },
  7.                 pipelineInitializerAction)
  8.                 {
  9.                     Username = "user",
  10.                     Password = "secret",
  11.                     XmppDomain = "server.com",
  12.                     HostnameResolver = new SrvNameResolver(),
  13.                 };

You can then use the RequestAckAsync function of the StreamManagement handler to request acks and validate them.
Let me know if this helps.

Alex
Avatar
lampo #5
Member since May 2018 · 6 posts
Group memberships: Members
Show profile · Link to this post
This really help, you do a great job and provide so good and easy to use interface.

But as you said "fully end to end like receipts. Or just using IQs", can you also give me an example how to use this extesions when sending message on client, big thanks!
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
IQ (InfoQuery) packages in XMPP implement the request/response pattern. Every Iq you send MUST have a reply back to you. Even if its and Iq which sets something or executes something. There is always a reply which tells you success or failure. And when you get no reply for a certain period of time you can assume that something wet wrong or the package was lost. Then you can resent.

Track delivery with IQs in Matrix is a single liner, because its all build in.

  1. // send the request and await the response
  2. var resultIq = await xmppClient.SendIqAsync(yourRequest, optionalTimeout);

See also:
https://dev.matrix-xmpp.io/docs/info-query/

Messges in XMPP are often send and forget. So You send them, but don't track the delivery or a response.
But there are also extensions for messages to track receipts of delivery. This will give you a similar mechnism of tracking the end to end delivery of messages.

E.g. XMPP extensions XEP-0184: Message Delivery Receipts

You can request a receipt of every message you send and track the delivery end 2 end. The receiving client will just send the delivery notification message back to you when a message was received. The delivery receipt includes the unique id of your message.
Doing this is also very easy with MatriX. The sender could then await the receipt also in a single line of code like above for IQs. You only need to pass the predicate to MatriX so that the response can be tracked.

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: