I’m in the process of implementing msgs_acks
back to the telegram server for “content” messages sent with a response received. I get the above error right off the bat, after the first attempt at acknowledgment to the first content message (initConnection
using getNearestDc
, wrapped by invokeWithLayer
). The sequence of events are listed below. What am I doing out of sequence?
The outgoing message_id is: 6337647283454888960L, which is what I am trying to ack. -->
is sent TO the server, <--
is returned FROM the server.
psuedo code of initConnection call
--> ('method_call: ', 'invokeWithLayer', {'query': ['initConnection', 'query': 'getNearestDc']})
(' message_id: ', 6337647283454888960L)
result of initConnection
<--('TL deserialize: x = ', {'MessageContainer': [
{'msg': {u'new_session_created': {u'first_msg_id': 6337647283454888960L, u'unique_id': -8353387387127432890L, u'server_salt': -717652021221374449L}}, 'seqno': 1, 'msg_id': 6337647285940375553L},
{'msg': {u'msgs_ack': {u'msg_ids': [6337647283454888960L]}}, 'seqno': 2, 'msg_id': 6337647285940441089L}]})
result of getNearestDc
<--('TL deserialize: x = ', {u'req_msg_id': 6337647283454888960L, u'result': {u'nearest_dc': 3, u'country': 'US', u'this_dc': 1}})
attempt to ack back to the server for getNearestDc
-->('method_call: ', 'msgs_ack', {'msg_ids': [6337647283454888960L]})
(' message_id: ', 6337647284623120384L)
error!
('TL deserialize: x = ', {u'req_msg_id': 6337647284623120384L, u'result': {u'error_message': 'Invalid msgs_ack query', u'error_code': -500}})
2
Answers
It turns out the
'Invalid msgs_ack query'
error message had nothing to do with sequence numbers. I improperly serialized the msg ids vector, so the query was indeed invalid.Once I got that corrected I got another error:
'error_code': 64
, which indicates an invalid container. At least it knows it's a container! I'll try a few things to correct the container and post another question if I run into trouble.The simplest way to explain this is as follows:
dispatch_timer
for handling pending msg_ids, it should fire say every 2-3 minutesmsg_id_list
msg_id_list
, add them to the message(s) you are about to send in a message container. Clear themsg_id_list
dispatch_timer
fires, and you havemsg_id_list
count > 0
, then simple sendmsgs_ack(msg_id_list)
. Clear themsg_id_list
I have used this method to successfully handle msg_acks without any issues.