XMPP plugin request

Got a good idea? You can suggest new features here.
Post Reply
Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

XMPP plugin request

Post by Snowbird » Wed Nov 15, 2017 10:29 am

Hello everyone,

I was wondering if there was any plan on creating an XMPP plugin ? there were some attempts in the past but they don't work as of today, see below the 2 topics I've found :
1. viewtopic.php?f=10&t=2895
2. viewtopic.php?f=9&t=6797

Maybe there's no need to recreate anything and "just" a rework might be sufficient ? I don't know, but for sure it would be really nice to have an XMPP plugin, I know there are many other alternatives such as PushBullet (and others), but with XMPP we don't need to rely on any specific platform (android, windows, etc.), nor specific App or program.

The ultimate goal, is to "talk" with EG with any XMPP client (android, Windows, Linux, Mac, etc.), just run your client and send instant messages to EG, and make EG do things for you and then let EG "talk back" to your XMPP client.

Would be soooooo nice ;)

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Sun Nov 19, 2017 7:58 pm

anyone ? :)

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Mon Dec 04, 2017 1:59 pm

is there anyone who is using one of the two old plugins I have mentioned above ? if yes, with what version and build of EG ? is there anything special to do to make them work ?

Thanks.

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Tue Dec 19, 2017 8:52 pm

give me a little while and i will take a look see. post me the errors you are getting also it will help me track down the problem.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 10:25 am

ok great !

I think I know why I get errors, it's quite easy to understand, when the XMPP account is idle for too long (couple of hours), idle means not sending and/or receiving any message during a certain amount of time, the server disconnects you on its own ! So if I try to send a message, obviously I get an error, see below :

Code: Select all

20/12 09:28:28            Traceback (most recent call last):
20/12 09:28:28              Python script "78", line 4, in <module>
20/12 09:28:28                eg.plugins.XMPP.SendXMPP("my_own_message", u'my_xmpp_account@server.com')
20/12 09:28:28              File "C:\ProgramData\EventGhost\plugins\XMPP\__init__.py", line 238, in __call__
20/12 09:28:28                client.send(xmpp.Message(jid, message))
20/12 09:28:28              File "C:\ProgramData\EventGhost\plugins\XMPP\xmpp\dispatcher.py", line 367, in send
20/12 09:28:28                self._owner_send(stanza)
20/12 09:28:28              File "C:\ProgramData\EventGhost\plugins\XMPP\xmpp\transports.py", line 198, in send
20/12 09:28:28                self._owner.disconnected()
20/12 09:28:28              File "C:\ProgramData\EventGhost\plugins\XMPP\xmpp\client.py", line 129, in disconnected
20/12 09:28:28                for i in self.disconnect_handlers: i()
20/12 09:28:28              File "C:\ProgramData\EventGhost\plugins\XMPP\xmpp\client.py", line 137, in DisconnectHandler
20/12 09:28:28                raise IOError('Disconnected from server.')
20/12 09:28:28            IOError: Disconnected from server.
The error is self explanatory : if there is no established connection > you can't send any messages :)

In other words, we need to re-connect to the XMPP server when a disconnection occurs, for example when I switch from one WiFi Access Point to another, or when I put my computer in sleep mode for a long period of time (at night for example) and powered it on again in the morning. So far, the only workaround I've found is to disable the XMPP plugin when a System.Suspend event is fired (it logs out cleanly from the XMPP server), and I re-enable the plugin when a System.Resume event is fired, this way I can cleanly log out/in from the server. Now the only thing that is still bothering me is when the network breaks (no more internet, or change of WiFi AP), for this I don't have any workaround as of now.

So now you have a complete comprehension of the problem, I think it would be useful to create something to detect a network or internet connection loss in the EG core ? and fire an event when connection is lost/recovered, this way we can rely on it to cope with this particular issue (and I'm sure it would be needed for many other usages). Let me know what you think about all this.

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Wed Dec 20, 2017 3:30 pm

See if this fixes the issue. It should. I overrode the DisconnectHandler and set it to reconnect the server in the event it was disconnected. The only thing i am unsure of is if whatever was being done at the time the IOError took place will continue or not. I may need to adjust for that. I am sure you will let me know what I have to fix.

I also changed the threading loop. I set it up to use threading.Event for it's loop and i added a wait interval of 0.1 seconds. There was no wait of any kind setup in this and that had to have been causing abnormally high CPU use. if that was the case the 0.1 wait will drop the CPU use way down into single digits or possibly 0. I also change the closing of the thread loop so EG won't stall for 5 seconds when you go to exit it.
Attachments
XMPP-1.1.0.egplugin
(68.35 KiB) Downloaded 35 times
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 3:54 pm

ok, thank you, i will give it a try shortly and let you know.

In the meantime could you please also add the fix about SSL I wrote here (without it, it won't work) :

viewtopic.php?f=10&t=2895#p49480

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 4:05 pm

ok, just tried it and things are bit better but not fixed ! :)

when I switch my WiFi AP, it doesn't reconnect, and when I try to send a message I get :

Code: Select all

XMPP: Not Connected
if I disable/enable the plugin, It works.

is there a time out that I should wait between the 2 attempts ?

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Wed Dec 20, 2017 5:23 pm

let me make one change and see if that will fix it. I am pretty sure it will. I am going to add checking for the connection in the polling loop.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Wed Dec 20, 2017 5:32 pm

Here ya go. see if this does the trick for ya. any message that are sent while it is attempting to reconnect will get that not connected error. I set that error in place to not get a TraceBack that could potentially stop the plugin. But in doing that the disconnect handler never gets called. So i used the same mechanism i used to check the connection in the polling loop. So it will try to reconnect the thing every 0.1 seconds until it is able to.
Attachments
XMPP-1.1.1.egplugin
(68.37 KiB) Downloaded 36 times
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 5:53 pm

Ok, I will try it in about 3 hours and will let you know.

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 10:31 pm

unfortunately exactly the same thing ...

While you're at it, don't forget to include the modification of the file : transports.py as I mentioned it in my previous post.

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Wed Dec 20, 2017 10:38 pm

where?? what modifications??

you don't say anything about any modifications.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4309
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: XMPP plugin request

Post by kgschlosser » Wed Dec 20, 2017 10:41 pm

I do not know how fast you are trying to send a command after switching to wifi. but do me a favor. make sure your connection is good first by loading a non cached webpage. to make sure then try it and see if it works.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 349
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP plugin request

Post by Snowbird » Wed Dec 20, 2017 10:42 pm

just check about 8 posts above this one :)

viewtopic.php?f=5&t=9936&p=49501#p49486

Post Reply