XMPP delays.

Started by ofca, December 28, 2014, 01:27:53 AM

Previous topic - Next topic

djex81

Ok so I've come up with a temporary fix for the XMPP delay issue. I found a python library for sending messages via XMPP and it works quite good. I tested it on Windows but it should work on linux and unix. Below are the instructions for Windows.

1. Download and install Python 2.6.6 from here: https://www.python.org/download/releases/2.6.6/
2. Download and install xmpppy 0.4.0 from here: http://downloads.sourceforge.net/project/xmpppy/xmpppy/0.4.0/xmpppy-0.4.0.win32.exe
3. Create a folder any where to hold the sendXMPP.py script. I used C:\NetXMS\XMPP_FIX\

File: sendXMPP.py (not my code, its modified example code on the xmpppy project site)

#!/usr/bin/python
# \$Id: xsend.py,v 1.8 2006/10/06 12:30:42 normanr Exp \$
import sys,os,xmpp,time

if len(sys.argv) < 2:
print("Syntax: xsend JID text")
sys.exit(0)

tojid=sys.argv[1]
text=' '.join(sys.argv[2:])

jidparams={}

jidparams['jid']='[email protected]'
jidparams['password'] = 'LOGN_PASSWORD'

jid=xmpp.protocol.JID(jidparams['jid'])
cl=xmpp.Client(jid.getDomain(),debug=True)

con=cl.connect(('YOUR_XMPP_SERVER_HERE',5222),  use_srv=False)

if not con:
print("could not connect!")
sys.exit()
print("connected with",con)
auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource())
if not auth:
print("could not authenticate!")
sys.exit()
print("authenticated using",auth)

# cl.SendInitPresence(requestRoster=0)   # you may need to uncomment this for old server
id=cl.send(xmpp.protocol.Message(tojid,text))
print("sent message with id",id)

time.sleep(1)   # some older servers will not send the message if you disconnect immediately after sending

cl.disconnect()


4. Take the above code and create a sendXMPP.py file in the folder created in step 3. Make sure to edit the script to use your own login, password and xmpp server.
5. Inside netxms add an action and fill out the fields as follows:

Name: External Send XMPP
Type: Execute command on management server
Command: C:\\Python26\\python.exe C:\\NetXMS\\XMPP_FIX\\sendXMPP.py "ACCOUNT_TO_SEND_TO" "%m"

Note: Your python path and sendXMPP.py path might be different so change the paths in the command accordingly.

6. Now add the action you just created in the desired event processing policy and it should be ready to go.

If you want to send to multiple accounts at once you will have to either create multiple actions for each account or modify the python script.

I don't have time at the moment to try it on linux. Maybe you could give it a go ofca.

ofca

I already have similar script for some other stuff, but never got around to adapting it to netxms. I suppose I'll do it now that you've shown how to do it :) - I still would very much like to have it fixed in NetXMS tough.

Victor Kirhenshtein

Hi,

I'll try to reproduce this issue on my system and fix it. Have registered it in bug tracker: https://dev.raden.solutions/issues/806.

Best regards,
Victor

Tatjana Dubrovica

Hi.

I have tested it with our local jabber server and using Hangouts(Gmail account) all worked immediately. Was not possible to reproduce delay.

We added some patches from current libstrophe development branch to ours that could cause this attitude. Also added reconnect in case of disconnect.

Please test it in next release(2.0-M5).

multix

I am trying to use sendxmpp for 2 months and having same problem. When this happens, my server's event processing queue is increasing. I searched for alternative to send xmpp messages, and saw sendxmpp for linux. I tested it and it is fast enough (I tried with netxms at 25 messages per second and sucsess.).

ofca

Just a note, that this issue still exists in 2.0-RC1, and changelog doesn't seem to indicate that anything is changed in RC2.

Victor Kirhenshtein

In RC2 we add separate queue for XMPP messages, so at least they will not block event processing.

Best regards,
Victor

ofca

OK then, I'll upgrade and see what happens :)