Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
sldr #1
Member since Feb 2018 · 15 posts
Group memberships: Members
Show profile · Link to this post
Subject: MatriX.vNext Logging
It seems that Matrix XMPP SDK has the following available to it:
  1. xmppClient.OnReceiveXml += new EventHandler<TextEventArgs>(XmppClientOnReceiveXml);
  2. xmppClient.OnSendXml += new EventHandler<TextEventArgs>(XmppClientOnSendXml);

I don't seem to find the equivalent in Matrix.vNext. I have been able to do the following that I think is getting all the received xml data:
  1.       x.XmppXElementStreamObserver.Subscribe(el => {
  2.         Console.WriteLine("Xmpp:");
  3.         Console.WriteLine(el.ToString());
  4.       });

Is it available and I can't find it? You know one of those I can't see the code thru all the statements, methods and classes. ;-)

Thanks,
SLDR
(Stephen L. De Rudder)
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Its described here in the docs:
https://matrix-xmpp.io/docs/logging

Alex
This post was edited on 2018-03-14, 13:03 by Alex.
Avatar
sldr #3
Member since Feb 2018 · 15 posts
Group memberships: Members
Show profile · Link to this post
I am able to log both the send and recv data. Thank you for you help once again. Here are a couple of thoughts I had while doing this.

You may want to update your doc to disable compression:
  1. var xmppClient = new XmppClient(pipelineInitializerAction)
  2. {                
  3.     Username = "username",
  4.     Password = "secret",
  5.     XmppDomain = "jabber.org",    
  6.     Compression = false;
  7. };
As soon as compression is turned on the rest of the SEND and RECV data is unreadable.

While logging the data that is going on the wire is great and can be a HUGE help in debugging at that level it does have some drawbacks. The data can overrun a single SEND or RECV and it looks like SEND is being called over n over again because I keep getting empty SEND log entries (about 2 mins apart). I have included a portion of the log that shows the overruns and empty SEND log entries. In my opinion, having the ability to log at the "XML level" would be nice.

Note: I changed a few things to protect the guilty n I didn't use code=csharp, but feel free to edit it if you prefer.

info: EMailIM.Program[0]
      RECV: <presence from="XXXXXXXXX@imXXXXXXXXcom/XXXXXXXXXXX" to="XXXX@imXXXXXXXXcom/EMailIM"><show>xa</show>
<priority>0</priority>
<c xmlns="http://jabber.org/protocol/caps" node="http://www.apple.com/ichat/caps" ver="1000" ext="maudio mvideo avcap ice avavail vi
info: EMailIM.Program[0]
      RECV: deo audio"/><x xmlns="http://jabber.org/protocol/tune"/><x xmlns="vcard-temp:x:update"><photo>7EDC5AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX569A</photo>
</x>
<x xmlns="http://www.apple.com/xmpp/idle"><idle-since>0000-00-00T00:00:00Z</idle-since>
</x>
</presence>
info: EMailIM.Program[0]
      RECV: <presence type="unavailable" from="XXXXXX@imXXXXXXXXcom" to="XXXX@imXXXXXXXXcom/EMailIM">
<status>XXXX</status>
</presence>
info: EMailIM.Program[0]
      SEND:
info: EMailIM.Program[0]
      SEND:
info: EMailIM.Program[0]
      SEND:
info: EMailIM.Program[0]
      SEND:
info: EMailIM.Program[0]
      SEND:

I do realize that I could check the object for null or 0 length to stop the empty SENDs. While it would be a lot of work it may even be possible to un-overrun the data or just deal with the split data.

Thanks,
SLDR
(Stephen L. De Rudder)
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Will add a note on compression to the docs, thanks.

It's the nature of buffers and sockets that a packet can be split over multiple chunks on send and receive. There is lots of magic inside of MatriX in the XML parser to put the packets together. But the logging handler gets injected before all those other encoders, decoders and handlers.
The idea is to get the raw data, before any other logic in Matrix or you application code touched and modified it. Otherwise it would be useless to debug certain type issues in application code.

You could merge those packets in your logging handler, or build your own handler(s) and inject it to the pipeline after matrix deserialized the incoming and serialized the outgoing xml.

The empty sends are spaces which get sent from the KeepAlive handler, you could ignore them in the logging handler. They should appear every 120 seconds by default if you have not sent any other data for this period.

When you are interested on how the pipeline is build in MatriX you can take a look at the setup here:
https://github.com/matrix-xmpp/matrix-vnext/blob/master/sr…

Edit: Also logging on socket level was always a big feature request for the previous version of MatriX
This post was edited on 2018-03-14, 15:24 by 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: