Sending Google Cloud Notifications with python and XMPP

2016 May 2 at 13:31 » Tagged as :python, android, scaffold, xmpp, gcm, ccs, xmpppy,

Have you seen the sample code in Android Docs? for sending GCMs with python an XMPP? Sure you have. You probably know that import xmpp here refers to the xmpppy library.

xmpppy hasn't been updated for at least a decade. Heck there's even an ICQ number for the author on the project home page. And yes, the project is hosted on Source Forge!! Never mind all that. the real problem is that xmpppy doesn't play very well with modern versions of openssl and god knows what other incompatibilities there are.

  File "push/", line 319, in 
  File "/..../push/", line 140, in setup_xmpp
    self.xmpp_client.connect(server=(settings.CLOUD_MESSENGER['SERVER'],self.params['PORT']), secure=1, use_srv=False)
  File "/usr/local/virtualenv-django18/lib/python2.7/site-packages/xmpp/", line 200, in connect
    if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure<>None and not secure: return self.connected
  File "/usr/local/virtualenv-django18/lib/python2.7/site-packages/xmpp/", line 178, in connect
  File "/usr/local/virtualenv-django18/lib/python2.7/site-packages/xmpp/", line 281, in PlugIn
    if now: return self._startSSL()
  File "/usr/local/virtualenv-django18/lib/python2.7/site-packages/xmpp/", line 316, in _startSSL
    tcpsock._sslIssuer = tcpsock._sslObj.issuer()
AttributeError: '_ssl._SSLSocket' object has no attribute 'issuer

So you might shop around for another python xmpp library, there are quite a few. But the majority of these libraries seem to be forks of xmppy itself but these forks have merely copied the files and just left them there. Twisted and SleekXMPP seem to be the only libraries and are being maintained. So let's see if we can modify google's sample to work with either of these two and in the long run that really is what you should do. But for now there is one, just one fork ( that's only two years behind. You will have to install it manually though.


source /usr/local/myvirtualenv/bin/activate
pip uninstall xmpppy
cd xmpppy-master
python build
python install

Hopefully the next breaking change to openssl is a long way away.