XMPP Plus

Questions and comments specific to a particular plugin should go here.
Snowbird
Experienced User
Posts: 340
Joined: Fri Jul 03, 2009 10:04 am

Re: XMPP Plus

Post by Snowbird » Wed May 23, 2018 7:14 am

you could check this easily, try to add the plugin again (even if it's already installed), and you will see the version of the plugin, then just press "Cancel" when you're done. But, yes your idea is good, we should be able to see the version of any plugin upon start :)

Kevin, yesterday my internet connection went down for 2 or 3 minutes and guess what ? EG couldn't reconnect to the xmpp server, so it's not yet fixed ;) as soon as I restarted EG, it worked right away.

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

Re: XMPP Plus

Post by kgschlosser » Wed May 23, 2018 9:03 pm

I have found the issue.

even tho this code gets executed

Code: Select all

        while not self._client.connect(address, reattempt=False):
            if self._socket_error:
                self.shutting_down_event.wait(10)
                if self._shutting_down_event.isSet():
                    return
                t = threading.Thread(
                    target=self._connect
                )
                t.daemon = True
                t.start()
                return

            self._shutting_down_event.wait(2)
            if self._shutting_down_event.isSet():
                return 
it is supposed to loop if a server connection is not made. well guess what.. this thing doesn't loop because if there is a socket error it will still report back that he server connection has been made. guess the author of sleekxmpp made a HUGE mistake in the code.

I have coded around this to fix that and several other issues, one being the session ended getting called back after the socket error. the session should end first then report the socket error.

I have also added the reason for the socket disconnection as a payload to the socket error event. This way we will know why the thing has disconnected.

It will loop until the end of time. or until your computer stops running. every 10 seconds trying to reconnect.. I have tested this bugger upside down left and right it works and I have not been able to find a glitch in it. But as always you have my famous warranty. the same warranty i give to people when i work on their cars.. the tail light warranty. as soon as i see your tail lights your warranty has expired


I also added the version number to the name of the plugin so when the plugin loads you will see it in the log... :shock:

check this thing first before i attach it to the first post please.
Attachments
XMPPPlus-1.2.5b.egplugin
(538.76 KiB) Downloaded 16 times
If you like the work I have been doing then feel free to Image

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

Re: XMPP Plus

Post by Snowbird » Thu May 24, 2018 6:29 am

good job !! I guess my final clue helped you a little ;).

I installed it a few hours ago, so far so good, I will let you know what happens in the next couple of days. BTW, I really like the version being displayed ;) it should be in every future plugins ;)

HTPCanwender
Experienced User
Posts: 59
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: XMPP Plus

Post by HTPCanwender » Thu May 24, 2018 7:19 am

I just started testing. I will keep you informed what is happening.

Thank You

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

Re: XMPP Plus

Post by kgschlosser » Thu May 24, 2018 7:29 am

well i have been looking at the code trying to figure out why the thing was not reconnecting. and why there were only 2 socket disconnects. so i was thinking it was it was an issue with how i have the timing and thread locks set up. and that is what i have been focusing on... i wasn't paying attention to the one clue. the 2 socket error events.. my system was doing the same thing as well but it was doing it on a single connection. i then noticed that and said to myself.... hmmm... 2 events for the single drop in connection. when i got the thing to spit out the error with it it all became apparent. the first error is from the actual drop in connection. the second is from something that is getting sent down the broken socket. it doesn't always produce 2 errors. so that clued me in to the fact that the loop was returning true even if there is no connection made. thus not running my code.
If you like the work I have been doing then feel free to Image

HTPCanwender
Experienced User
Posts: 59
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: XMPP Plus

Post by HTPCanwender » Thu May 24, 2018 5:56 pm

Until now, everything works fine.

I have two additional proposals.

1) I have installed a XMPP client on my android smartphone to control my homeserver with special commands. When I am moving (different WLANs and phone cells) I am getting really many "Incoming.Presence" events. It would be nice if it is possible to switch them off in the plugin configuration menu.

2) A "Get Sender" command could be added.

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

Re: XMPP Plus

Post by kgschlosser » Thu May 24, 2018 6:42 pm

you can switch them off.

and you can get the sender of a message or a presence.


the payload is a python object. that object represents what was received and it has several functions and properties attached to it.


so as far as the presences go if you put this code into a python script

Code: Select all

presence = eg.event.payload

if presence.sender == 'ENTER SENDER JID HERE':
    presence.unsubscribe()
and if you want to get the senders name

Code: Select all

message = eg.event.payload
result = message.sender
with the code above you can access the sender by using eg.result. an example would be the osd action. if you put {eg.result} in the text to display field it will grab the senders name.

the available objects caused by events and what you can do with them


presence.priority - gets the priority of the presence
presence.type - the presence type
presence.sender - the jid of the person who sent the presence change
presence.status - the custom message supplied by the user in a presence change
presence.unsubscribe() - unsubscribes from getting presence announcements from that sender


message receipt events will only show if the person sending the message requests one.
message_receipt.type
message_receipt.sender
message_receipt.room
message_receipt.body
message_receipt.subject
message_receipt.send_receipt() - send a receipt for the message

message.type - the type of message
message.sender
message.room - the room the person is in that is sending the message (pm)
message.body - the message
message.subject - the subject
message.send_reply(msg) - using this function you would replace the msg with the reply you want to send.
If you like the work I have been doing then feel free to Image

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

Re: XMPP Plus

Post by Snowbird » Thu May 24, 2018 7:17 pm

in the mqtt plugin there is a neat feature that shows us when the connection is lost and it's trying to reconnect, here's a sample :

Code: Select all

24/05  21:07:07   Retrying to re-connect
24/05  21:07:07   MQTT Client: Trying to reconnect with...
24/05  21:07:12   Retrying to re-connect
24/05  21:07:12   MQTT Client: Trying to reconnect with...
24/05  21:07:17   Retrying to re-connect
24/05  21:07:17   MQTT Client: Trying to reconnect with...
24/05  21:07:22   Retrying to re-connect
24/05  21:07:22   MQTT Client: Trying to reconnect with...
24/05  21:07:27   Retrying to re-connect
24/05  21:07:27   MQTT Client: Trying to reconnect with...
24/05  21:07:32   Retrying to re-connect
24/05  21:07:32   MQTT Client: Trying to reconnect with...
I'm sure you know what is the next question :) could you implement this in XMPP ?

HTPCanwender
Experienced User
Posts: 59
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: XMPP Plus

Post by HTPCanwender » Thu May 24, 2018 7:26 pm

Here it is. The connection to the XMPP server got lost and was new established.

09:13:13 XMPPPlus.boekifhz@jabber.de.AuthenticationSuccessful
09:13:13 XMPPPlus.boekifhz@jabber.de.SessionStarted
09:13:13 XMPPPlus.boekifhz@jabber.de.Incoming.Presence <eg.CorePluginModule.XMPPPlus.Presence object at 0x07403270>
09:13:13 XMPPPlus.boekifhz@jabber.de.Incoming.Presence <eg.CorePluginModule.XMPPPlus.Presence object at 0x0B63F0D0>
09:13:13 XMPPPlus.boekifhz@jabber.de.RosterReceived

21:18:45 XMPPPlus.boekifhz@jabber.de.SessionEnded
21:18:45 XMPPPlus.jabber.de:5222.SocketError '[Errno 10060] Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat'
21:20:00 XMPPPlus.boekifhz@jabber.de.AuthenticationSuccessful
21:20:00 XMPPPlus.boekifhz@jabber.de.SessionStarted
21:20:00 XMPPPlus.boekifhz@jabber.de.Incoming.Presence <eg.CorePluginModule.XMPPPlus.Presence object at 0x06A81C10>
21:20:00 XMPPPlus.boekifhz@jabber.de.Incoming.Presence <eg.CorePluginModule.XMPPPlus.Presence object at 0x0BB48F70>
21:20:00 XMPPPlus.boekifhz@jabber.de.RosterReceived

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

Re: XMPP Plus

Post by Snowbird » Thu May 24, 2018 7:43 pm

it took 5 minutes to reconnect ? or your connection or the server was down for 5 minutes ?

HTPCanwender
Experienced User
Posts: 59
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: XMPP Plus

Post by HTPCanwender » Thu May 24, 2018 7:48 pm

From 21:18:45 to 21:20:00 there are only 75 seconds, not 5 minutes.

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

Re: XMPP Plus

Post by Snowbird » Thu May 24, 2018 7:50 pm

oh, sorry i didn't read well your log
so everything is fine, that's cool ;)

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

Re: XMPP Plus

Post by kgschlosser » Thu May 24, 2018 7:57 pm

it does show you when the connection is lost and when it is re established.
XMPP.png
If you like the work I have been doing then feel free to Image

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

Re: XMPP Plus

Post by kgschlosser » Thu May 24, 2018 8:00 pm

the plugin is only going to spit out connection failures attempts if it is a socket error. if you want events for a general connection failure i can do that as well.
If you like the work I have been doing then feel free to Image

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

Re: XMPP Plus

Post by Snowbird » Thu May 24, 2018 8:02 pm

ok, fine but will it repeat over and over when the connection can not be made ? this way we will know exactly how long the connection wasn't established.

Post Reply