Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
OliverHall #1
Member since Mar 2022 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: General stability question
Hi,
I'm trying to write an XMPP client using Xamarin.Forms and MatriX vNext looked like a good place to get a spring board into getting something working.

I have to admit, I've found the docs/samples (or rather lack of) makes the process pretty painful.  Finding some sample code to join a MUC room was luck, more than following any documentation pointers and the API is so LINQ heavy, without any API docs, I've found it very much a trial and error exercise to get things working.  I hope I'm just missing some rich repository of information, but I've looked and searched Google and there doesn't appear to be anything?

So - I did eventually get a client to join a group chat, and post a message using native Windows .Net Framework.

The same code moved to Xamarin.Forms and targeting an Android platform nearly works, and I can see my client joining the MUC room, but the SendAsync call never returns (eventually times out) (the offending line is shown below).

  1. await _xmppClient.SendAsync(createRoomStanza, predicate, 10000, CancellationToken.None);

Should the library work in this context or am I flogging the proverbial "dead horse" with MatriX vNext?

I see that the last NuGet update is from 2020; is this project dormant now?  XMPP support for .Net seems thin on the ground sadly!  Any other suggestions?  I don't need anything particularly fancy.

Many thanks,
Oliver
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello Oliver,

MatriX vNext works fine on Xamarin. We have many users of it on Xamarin. and we have hundreds of users worldwide using it in many different applications on all kind of platforms.

Some hints for Xamarin development:
When MatriX vNext was first released we decided to use the great DotNetty networking stack which offers great extensibility and high performance, also for server applications. But DotNetty development seems to be abandoned by the developers and also support seems non existing in the GitHug pages and other channels. Also in Mono which is being used by Xamarin there have been some TLS issues with DotNetty.
Because of the reasons above we replaced the DotNetty networking stack with standard .NET sockets and websockets. We did this at the same time as we added .Net5 compatibility.
You can find the latest and stable code for this in the net5 branch here:
https://github.com/matrix-xmpp/matrix-vnext/tree/net5

Also recently I decided to rename MatriX vNext to XmppDotNet. Because there always has been confusion between MatriX and vNext and also with the Matrix chat protocol which is not related to XMPP. You can find pre-release packages for XmppDotNet on Nuget. All the sources will be made open on GitHub soon. Currently XmppDotNet is based on vNext`s net5 branch. Only the namespaces and packet names were changed.

For joining a GroupChat please look at the MucManager here in the sample code:
https://github.com/matrix-xmpp/matrix-vnext/blob/net5/exam…
This code will be extended soon and moved to XmppDotNet

MatriX is active in development. With the name change to XmppDortNet you can expect more activity on NuGet soon again.
But also XMPP is a stable protocol since 2 decades. Unless there are bugs or new extensions requested by users there is not really a reason for pushing new packages. Most of the recent changes are related to netCore, because there were many changes since the initial 1.0 release.

I am aware that documentation could be better. The forum here also offers a lot of help and I am always trying to offer quick help here. So when more questions come up then just ask.
The website repo for XmppDotNet will be made public as well soon. So help for docs from the community is welcome.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #1
Quote by OliverHall:
The same code moved to Xamarin.Forms and targeting an Android platform nearly works, and I can see my client joining the MUC room, but the SendAsync call never returns (eventually times out) (the offending line is shown below).

  1. await _xmppClient.SendAsync(createRoomStanza, predicate, 10000, CancellationToken.None);

how does your predicate look?

A predicate is usually used when the packet you send has a success or failure reply. It building a request/response pattern.
For joining a Muc room there is no immediate success/failure reply from the server. Many people send it without predicate as fire and forget.

The code I was referring to in my previous message is setting up a predicate to monitor incoming presence packets.
Joining a MUC room is just sending a Presence packet to the room. And when this succeeds the rooms sends you back the presence of all participants. This is what I take here as the success criteria. Even when no other participants are in the room yet, then the server needs to send back your own participation (presence) for this room. So at least 1 presence packet should come back to you.

  1. public async Task<XmppXElement> EnterRoomAsync(Jid jid, string nick)
  2. {
  3.     var createRoomStanza = CreateEnterRoomStanza(jid, nick, null, false, null);
  4.  
  5.     Func<XmppXElement, bool> predicate = e =>
  6.         e.OfType<Presence>()
  7.         && e.Cast<Presence>().From.Equals(jid, new BareJidComparer());
  8.  
  9.     return await XmppClient.SendAsync(createRoomStanza, predicate, 10000, CancellationToken.None).ConfigureAwait(false);
  10. }

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: