我在这里找到了讨论:如何断开我的 XMPPPY 客户端对象?最后说 .disconnect() 是正确的方法。
这是代码:
while True:
try:
client.Process(5)
if not client.isConnected:
client.reconnectAndReauth()
except KeyboardInterrupt:
client.disconnect()
break;
flush_queued_messages()
这是我按 ^C 时收到的错误
msg keys: [u'message_type', u'from', u'message_id']
DEBUG: socket got
DEBUG: socket got
DEBUG: socket got
^C DEBUG: socket sent </stream:stream>
DEBUG: socket error Socket error while receiving data
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/xmpp/transports.py", line 146, in receive
try: received = self._recv(BUFLEN)
SSLError: [Errno 8] _ssl.c:1415: EOF occurred in violation of protocol
DEBUG: client stop Disconnect detected
DEBUG: socket error Socket operation failed
此服务器代码来自使用https://developer.android.com/google/gcm/ccs.html上的 python 示例代码实现的 gcm 服务器
我实现了这一点,因为我的服务器在一段时间后停止接收消息(SEND 仍然可以) - 我想我可能有太多的活动连接。只是发送到服务器的消息没有被一致地接收。这是我还没有弄清楚的另一个问题。