带有Google GCM的Xmpp Python客户端 [英] Xmpp Python Client with Google GCM
本文介绍了带有Google GCM的Xmpp Python客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现一个连接Google Cloud Messaging的XMPP客户端。
我选择了库sleekxmpp。
在连接/认证期间,我的客户端发送GCM所需的第一个流:
< stream:stream to ='gcm.googleapis.com'xmlns:stream ='http://etherx.jabber.org/streams'xmlns ='jabber:client'xml:lang ='en'version ='1.0'>
但是,库无法解析答案,并且出现错误:
DEBUG连接到[2404:6800:4008:c00 :: bc]:5235
DEBUG ==== TRANSITION已断开 - > ;连接
DEBUG启动HANDLER THREAD
DEBUG加载事件运行器
DEBUG SEND(IMMED):< stream:stream to ='gcm.googleapis.com'xmlns:stream ='http:// etherx.jabber.org/streams'xmlns ='jabber:client'xml:lang ='en'version ='1.0'>
错误从XML流中读取错误。
DEBUG重新连接...
DEBUG SEND(IMMED):< / stream:stream>
INFO等待< / stream:stream>从服务器
DEBUG ==== TRANSITION connected - >已断开连接
DEBUG连接...
任何人有一个想法,为什么我得到这个? / p>
任何与GCM连接的python XMPP连接的例子都可能受到高度赞赏。
解决方案
您必须将use_ssl标志设置为True
xmpp = ClientXMPP('PROJECT_ID@gcm.googleapis.com' ,'API_KEY')
xmpp.connect(地址=('gcm.googleapis.com',5235),use_ssl = True)
I want to implement a XMPP Client that connect the Google Cloud Messaging.
I have picked up the library sleekxmpp.
During the connection / authentication, my client sends the first stream required by GCM:
<stream:stream to='gcm.googleapis.com' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
But, the library is not able to parse the answer and I get the error:
DEBUG Connecting to [2404:6800:4008:c00::bc]:5235
DEBUG ==== TRANSITION disconnected -> connected
DEBUG Starting HANDLER THREAD
DEBUG Loading event runner
DEBUG SEND (IMMED): <stream:stream to='gcm.googleapis.com' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
ERROR Error reading from XML stream.
DEBUG reconnecting...
DEBUG SEND (IMMED): </stream:stream>
INFO Waiting for </stream:stream> from server
DEBUG ==== TRANSITION connected -> disconnected
DEBUG connecting...
Any one has an idea why I get this?
Any example of a python XMPP connection to the GCM might be highly appreciated.
解决方案
You have to set the use_ssl flag to True
xmpp = ClientXMPP('PROJECT_ID@gcm.googleapis.com', 'API_KEY')
xmpp.connect(address=('gcm.googleapis.com', 5235), use_ssl=True)
这篇关于带有Google GCM的Xmpp Python客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文