gpt4 book ai didi

python - telegram.org 服务器返回的错误代码 35 是什么

转载 作者:行者123 更新时间:2023-11-28 22:33:52 40 4
gpt4 key购买 nike

我的客户端经常从 Telegram 服务器收到以下消息容器,看似随机:

{'MessageContainer': [{'msg': {u'bad_msg_notification': {u'bad_msg_seqno': 4, u'bad_msg_id': 6330589643093583872L, u'error_code': 35}}, 'seqno': 4, 'msg_id': 6330589645303624705L}, {'msg': {u'msgs_ack': {u'msg_ids': [6330589643093583872L]}}, 'seqno': 4, 'msg_id': 6330589645303639041L}]})

您可能会注意到:上面的'error code': 35,但没有说明该错误代码的含义。到目前为止,我一直忽略它,但这不是一个好的长期解决方案恕我直言。知道该错误代码的含义吗?

最佳答案

有一组与bad_msg_seqno 相关的错误

来自文档:

Here, error_code can also take on the following values:

  1. msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)
  2. msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)
  3. an even msg_seqno expected (irrelevant message), but odd received
  4. odd msg_seqno expected (relevant message), but even received

正式定义: Message Sequence Number (msg_seqno)

a 32-bit number equal to twice the number of “content-related” messages (those requiring acknowledgment, and in particular those that are not containers) created by the sender prior to this message and subsequently incremented by one if the current message is a content-related message. A container is always generated after its entire contents; therefore, its sequence number is greater than or equal to the sequence numbers of the messages contained in it.

注意事项:

  1. 每个新 session 都从 seq_no = 1 --> (0 * 2) + 1 开始
  2. 您发送的每个序列号的计算公式为:(number_of_content_messages_ already_sent * 2) + 1 因此您发送的所有序列号始终是奇数
  3. 一个容器消息seq_no == 其内容消息的最大seq_no
  4. 服务器将始终用正确的 server_seq_no 回复您,它应该比您目前正确的 max seq_no 大 1。
  5. 因此,一个好的检查/seq_no 校正方案是使用最新收到的server_seq_no(应该始终是偶数)来确认您的current-expected seq_no 应该是什么, 并根据需要进行调整。

上述技术对我有效,可以完全避免这些间歇性的错误消息。

关于python - telegram.org 服务器返回的错误代码 35 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39515953/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com