Not logged in. · Lost password · Register
Forum: MatriX RSS
Page:  1  2  next
humba #1
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
Subject: Ping Handler not working on vNext
Cisco's UCCX 12.6 seems to be sending me pings after a certain amount of inactivity. Then cuts my connection after 30 seconds. So I suspect, it expects a response to these pings. Is there some facility I can use to automatically respond to these requests?
I'm on vNext..

@edit: found https://forum.ag-software.net/thread/2116-Handler-for-XMPP…, where it states that the ping handler is active by default. But, in my case, no response is being sent for an inbound ping.

When I activate packet logging, I see this

  1. 15:54:38.212 0|Information|RECV: <iq type="get" id="116-171" from="srvccx12.nxodev.intra"
  2. to="pmgr_agentmonitoring@srvccx12.nxodev.intra/pmgr"><ping xmlns="urn:xmpp:ping"/></iq>
  3. 15:55:08.223 0|Information|RECV: </stream:stream>

I'm not seeing any SEND entries, so there's no response. Do I have to register the handler somehow?
This post was edited on 2021-08-13, 17:01 by humba.
Avatar
Alex #2
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I think I miscommunicated in the other thread. The Ping Handler exists in MatriX, but its not added to the pipeline and enabled by default.
When you add the handler it should work.

Alex
humba #3
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
So what's the correct code to enable the ping handler? The code in the other thread doesn't work.. XmppPingHandler does require a type.

@edit: I tried this but it didn't take
  1. var pipelineInitializerAction = new Action<IChannelPipeline, ISession>((pipeline, session) =>
  2. {
  3.     if (Configuration.ActivatePacketLogging)
  4.     {
  5.         ILogger logger = new MyLogger(Log);
  6.         pipeline.AddFirst(new XmlLoggingHandler(logger));
  7.     }
  8.     if (Configuration.EnablePingHandler)
  9.         pipeline.AddBefore<XmppStanzaHandler>(new XmppPingHandler<PingIq>());
  10. });
This post was edited on 2021-08-16, 11:06 by humba.
Avatar
Alex #4
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I depends which branch of vNext you are using. I assume you are on master or use the Nuget packages.

A Ping Handler exists here in code. It should work when you just add an instance of this handler:
https://github.com/matrix-xmpp/matrix-vnext/blob/master/sr…

Best,
Alex
Avatar
Alex #5
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you can also easily add fragments of this code in your project if you want.
All it does is looking for Ping Iq Stanzas of type get, and then sending back a result response.

Alex
humba #6
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
I'm on the Nuget package - v2.4.5.

The handler I'm using is exactly the one you linked to, but I'm not seeing any ping responses being sent back :(
Avatar
Alex #7
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Have you tried to add iot directly to your code and debug it?
Or add MatriX from sources and debug it?

Alex
humba #8
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
I made a copy of the XmppPingHandler in my own project, and tried to register it

  1. if (Configuration.ActivatePacketLogging || Configuration.EnablePingHandler)
  2.                     {
  3.                         var pipelineInitializerAction = new Action<IChannelPipeline, ISession>((pipeline, session) =>
  4.                         {
  5.                             if (Configuration.ActivatePacketLogging)
  6.                             {
  7.                                 ILogger logger = new MyLogger(Log);
  8.                                 pipeline.AddFirst(new XmlLoggingHandler(logger));
  9.                             }
  10.                             if (Configuration.EnablePingHandler)
  11.                                 pipeline.AddBefore<XmppStanzaHandler>(new MyXmppPingHandler<PingIq>());
  12.                         });
  13.                         xmppClient = new XmppClient(pipelineInitializerAction)
  14.                         {
  15.  
  16.                         };

Now when I execute `pipeline.AddBefore`, I get a NullReferenceException at

   at Matrix.DotNettyExtensions.AddBefore[TBefore](IChannelPipeline channelPipeline, IChannelHandler handler)
   at CiscoXmppLib.XmppConnector.<StartOrRestartXmppSession>b__61_7(IChannelPipeline pipeline, ISession session) in D:\Personal\Documents\Visual Studio 2012\Projects\CiscoFinesseTest\CiscoXmppLib\XmppConnector.cs:line 362

Pipeline is this at the point of the exception

[Image: https://ibb.co/DYx3gMK]

@edit: if I instead of my own XmppPingHandler I register the standard `XmppPingHandler` the registration works fine, but doesn't send any responses. I'm now in the process of building things from github so I can put a breakpoint into the handler
This post was edited on 2021-08-16, 15:31 by humba.
humba #9
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
okay, built everything from the source, so I could debug the handler.

So, my packet logger still reports this

14:41:42.470 0|Information|RECV: <iq type="get" id="487-250" from="srvccx12.nxodev.intra" to="pmgr_agentmonitoring@srvccx12.nxodev.intra/pmgr"><ping xmlns="urn:xmpp:ping"/></iq>

And, the XmppPingHandler's message handling (lines 45, etc.) never fires... so, somehow the packet isn't recognized as a ping it seems. Any ideas?
Avatar
Alex #10
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #8
Have you tried AddLast or AddAfter instead of AddBefore?

I will try to include it in the Console Client example later today and give you an update then.
Avatar
Alex #11
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello Humba,

I just wrote a basic console application and this pipeline initializer with the buildin XmppPingHandler just works fine for me. I see the Pings come in and the replies beeing sent.

  1. var pipelineInitializerAction = new Action<IChannelPipeline, ISession>((pipeline, session) =>
  2. {
  3.    pipeline.AddAfter<XmppStanzaHandler>(new XmppPingHandler<Matrix.Xmpp.Client.Iq>());
  4. });

The XmppPingHandler in generic and you need to pass in a type. This is required because the Xml namespaces are different for client, servers and components. My code above is for client code.

Best,
Alex
humba #12
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
Did you see that I'm adding a logger, too? maybe that makes a difference. I also posted the output of the ping I'm getting.. could it be that it's not spec compliant somehow? If so, what kind of manual response should I be sending? Never having seen a fully working ping/response exchange I'm grasping at straws here :(
Avatar
Alex #13
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I had a logger in there as well.

All I did is modify the sample code from here:
https://github.com/matrix-xmpp/matrix-vnext/blob/master/ex…

1) After line 55 I added:
  1. pipeline.AddAfter<XmppStanzaHandler>(new XmppPingHandler<Matrix.Xmpp.Client.Iq>());

2) Run the code and login with user A
3) use another XMPP client and login with user B
4) send a Ping request from user A to user B and see if the code replies. The request was sent over the Xml console in Gajim from user B to user A

Alex
Avatar
Alex #14
Member since Feb 2003 · 4436 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #12
Quote by humba:
it's not spec compliant somehow? If so, what kind of manual response should I be sending? Never having seen a fully working ping/response exchange I'm grasping at straws here :(

The Xml you posted looks fine to me. Are you adding the handler at the correct position in the handler pipeline?
see: AddAfter<XmppStanzaHandler>
humba #15
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
I'm now using `AddAfter`instead of `AddBefore` and I'm registering an `XmppPingHandler` for `Matrix.Xmpp.Client.Iq` instead of `PingIq`and now it works.

Full code
  1. var pipelineInitializerAction = new Action<IChannelPipeline, ISession>((pipeline, session) =>
  2. {
  3.     if (Configuration.ActivatePacketLogging)
  4.     {
  5.         ILogger logger = new MyLogger(Log);
  6.         pipeline.AddFirst(new XmlLoggingHandler(logger));
  7.     }
  8.     if (Configuration.EnablePingHandler)
  9.         pipeline.AddAfter<XmppStanzaHandler>(new XmppPingHandler<Matrix.Xmpp.Client.Iq>());
  10. });
  11. xmppClient = new XmppClient(pipelineInitializerAction)
  12. {
  13.  
  14. };
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:
Page:  1  2  next
Forum: MatriX RSS