Messages being sent twice - second time in POST task=send


#1

We are seeing bizarre behavior on 3.0.4, with multiple bug that mean we’ve moved back to 2.8.3 because we cannot work around all of them. Here is a log with a new (to us) bug where its sending messages twice - once in the normal way, and then again in a POST ?task=send (there is no documentation of POST ?task=send pn http://smssync.ushahidi.com/developers/.

Here’s the full sequence pulled from the server logs and commented …

We send “Menu” to the phone.
It sends it to us … so far so good.
“POST /smssync HTTP/1.1” 200 156 “” “SMSSync-Android/v3.0.4”
{‘from’: u’+15104231767’, ‘message_id’: u’c69c53f0-b37e-4127-b905-544e11232121’, ‘secret’: u’10002’, ‘sent_timestamp’: u’1452144384000’, ‘message’: u’Menu’, ‘sent_to’: u’+15104231767’, ‘device_id’: u’10002’}

Which is forwarded to the sender correctly … so far so good except that sent_to is incorrect and would lead us to wrongly identify the phone number of the gateway if we hadn’t special cased it. (but that is posted as another bug)

We reply
{‘payload’: {‘task’: ‘send’, ‘messages’: [{‘to’: u’+15104231767’, ‘message’: ‘- REFILL\n- BALANCE\n- CREDIT\n- ADMIN’, ‘uuid’: ‘16139’}], ‘success’: ‘true’}}

Then we see …
GET /smssync?task=result&secret=10002

We reply with a list of the messages we are waiting for responses on, including the message 16139 just sent:
{‘message_uuids’: [‘16100’, ‘16102’, ‘16106’, ‘16108’, ‘16110’, ‘16112’, ‘16115’, ‘16117’, ‘16119’, ‘16124’, ‘16126’, ‘16128’, ‘16131’, ‘16133’, ‘16135’, ‘16139’]}

All looks good to here but we don’t get the expected response.
“POST /smssync?task=result&secret=10002 HTTP/1.1” 200 32 “” “SMSSync-Android/v3.0.4”{“message_result”:"[]"}

in particular it doesn’t have an answer for 16139

We respond with
{‘payload’: {‘success’: ‘true’}}
Which we are guessing is correct, there is no documentation on how we SHOULD respond to a POST task=result (that’s posted as a separate Forum topic)

The gateway then sends the same message to us again - this time with task=send&secret=10002 in the URL as well …."
POST /smssync?task=send&secret=10002 HTTP/1.1" 200 32 “” “SMSSync-Android/v3.0.4”
{‘task’: u’send’, ‘from’: u’+15104231767’, ‘sent_to’: u’+15104231767’, ‘secret’: [u’10002’, u’10002’], ‘sent_timestamp’: u’1452144384000’, ‘message’: u’Menu’, ‘message_id’: u’c69c53f0-b37e-4127-b905-544e11232121’, ‘device_id’: u’10002’}

Notice the bad ‘secret’ which is a list instead of a single value (posted as a separate bug)
but anyway it shouldn’t be sending this message again, and POST task=send is undocumented.

We ignore the body as we aren’t expecting any content in POST task=send, and since there are no outgoing messages respond with.
{‘payload’: {‘success’: ‘true’}}

This loop repeats indefinitely. We never got a POST task=sent.

Each time another message is sent from the gateway to the server, the list of messsges the server is waiting for a response for grows by one.