skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. The simplest way to explain this is as follows:

    1. Setup a dispatch_timer for handling pending msg_ids, it should fire say every 2-3 minutes
    2. Every inbound message you receive has a msg_id
    3. In your main receive loop, collate these msg_ids into a msg_id_list
    4. Each time you send a new request to the server, if you have pending msg_ids in your msg_id_list, add them to the message(s) you are about to send in a message container. Clear the msg_id_list
    5. If the dispatch_timer fires, and you have msg_id_list count > 0, then simple send msgs_ack(msg_id_list). Clear the msg_id_list

    I have used this method to successfully handle msg_acks without any issues.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search