CCS 需要多久关闭一次连接才能执行负载平衡?
how often exactly CCS needs to close down a connection to perform load balancing?
我有一个客户端 XMPP,但我从未收到过 CONNECTION_DRAINING 消息,所以我有这个问题,
CCS 需要多久关闭一次连接才能执行负载平衡?
这是我验证是否收到 CONNECTION_DRAINING 消息的代码的一部分
............................... more code
def message_callback(session, message):
global unacked_messages_quota
gcmData = message.getTags('data:gcm')
if gcmData:
print "alert, the connection is being drained and will be closed soon !!!!!!!!!!!!!"
gcm = message.getTags('gcm')
if gcm:
gcm_json = gcm[0].getData()
msg = json.loads(gcm_json)
if not msg.has_key('message_type'):
# Acknowledge the incoming message immediately.
send({'to': msg['from'],
'message_type': 'ack',
'message_id': msg['message_id']})
.......................................................... more code
我已经阅读了 https://developers.google.com/cloud-messaging/ccs
的文档
特别是这部分
Periodically, CCS needs to close down a connection to perform load
balancing. Before it closes the connection, CCS sends a
CONNECTION_DRAINING message to indicate that the connection is being
drained and will be closed soon. "Draining" refers to shutting off the
flow of messages coming into a connection, but allowing whatever is
already in the pipeline to continue. When you receive a
CONNECTION_DRAINING message, you should immediately begin sending
messages to another CCS connection, opening a new connection if
necessary. You should, however, keep the original connection open and
continue receiving messages that may come over the connection (and
ACKing them)—CCS handles initiating a connection close when it is
ready.
The CONNECTION_DRAINING message looks like this:
<message>
<data:gcm xmlns:data="google:mobile:data">
{
"message_type":"control"
"control_type":"CONNECTION_DRAINING"
}
</data:gcm>
</message>
通常至少每周一次,但根据负载情况可以更频繁。
我有一个客户端 XMPP,但我从未收到过 CONNECTION_DRAINING 消息,所以我有这个问题, CCS 需要多久关闭一次连接才能执行负载平衡?
这是我验证是否收到 CONNECTION_DRAINING 消息的代码的一部分
............................... more code
def message_callback(session, message):
global unacked_messages_quota
gcmData = message.getTags('data:gcm')
if gcmData:
print "alert, the connection is being drained and will be closed soon !!!!!!!!!!!!!"
gcm = message.getTags('gcm')
if gcm:
gcm_json = gcm[0].getData()
msg = json.loads(gcm_json)
if not msg.has_key('message_type'):
# Acknowledge the incoming message immediately.
send({'to': msg['from'],
'message_type': 'ack',
'message_id': msg['message_id']})
.......................................................... more code
我已经阅读了 https://developers.google.com/cloud-messaging/ccs
的文档特别是这部分
Periodically, CCS needs to close down a connection to perform load balancing. Before it closes the connection, CCS sends a CONNECTION_DRAINING message to indicate that the connection is being drained and will be closed soon. "Draining" refers to shutting off the flow of messages coming into a connection, but allowing whatever is already in the pipeline to continue. When you receive a CONNECTION_DRAINING message, you should immediately begin sending messages to another CCS connection, opening a new connection if necessary. You should, however, keep the original connection open and continue receiving messages that may come over the connection (and ACKing them)—CCS handles initiating a connection close when it is ready.
The CONNECTION_DRAINING message looks like this:
<message>
<data:gcm xmlns:data="google:mobile:data">
{
"message_type":"control"
"control_type":"CONNECTION_DRAINING"
}
</data:gcm>
</message>
通常至少每周一次,但根据负载情况可以更频繁。