[GH-ISSUE #60] messages that get the same ID are skipped #52

Closed
opened 2026-02-28 01:22:56 +03:00 by kerem · 8 comments
Owner

Originally created by @mandric on GitHub (Nov 20, 2012).
Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/60

i'm investigating the case where messages arrive into smssync and if the sync url is not valid SMSSync can hang up to the connection timeout value (currently 60 seconds) during that time if another message arrives it gets the same messageId and therefore gets skipped during syncing and also never appears in the pending list.

Originally created by @mandric on GitHub (Nov 20, 2012). Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/60 i'm investigating the case where messages arrive into smssync and if the sync url is not valid SMSSync can hang up to the connection timeout value (currently 60 seconds) during that time if another message arrives it gets the same messageId and therefore gets skipped during syncing and also never appears in the pending list.
kerem closed this issue 2026-02-28 01:22:57 +03:00
Author
Owner

@mandric commented on GitHub (Nov 21, 2012):

The problem is likely here: https://github.com/ushahidi/SMSSync/blob/master/smssync/src/org/addhen/smssync/ProcessSms.java#L384

<!-- gh-comment-id:10585447 --> @mandric commented on GitHub (Nov 21, 2012): The problem is likely here: https://github.com/ushahidi/SMSSync/blob/master/smssync/src/org/addhen/smssync/ProcessSms.java#L384
Author
Owner

@ghost commented on GitHub (Nov 22, 2012):

Well, it seems that messages are getting same ids most of the time:

mysql> select count(id), message_id from sms_incoming group by message_id;
+-----------+------------+
| count(id) | message_id |
+-----------+------------+
| 258 | 0 |
| 1 | 153 |
| 3 | 17 |
| 1 | 171 |
| 16 | 214 |
| 1 | 23 |
| 1 | 233 |
| 1 | 236 |
| 1 | 241 |
| 1 | 245 |
| 1 | 250 |
| 1 | 257 |
| 1 | 263 |
| 1 | 264 |
| 1 | 265 |
| 16 | 28 |
| 3 | 30 |
| 1 | 43 |
| 11 | 49 |
| 2 | 53 |
| 38 | 56 |
| 15 | 57 |
| 3 | 58 |
| 1 | 59 |
| 1 | 74 |
| 1 | 96 |
| 1 | 97 |
| 1 | 98 |
+-----------+------------+
28 rows in set (0.00 sec)

Why not just generate a hash of the message and use that as the ID?

<!-- gh-comment-id:10634534 --> @ghost commented on GitHub (Nov 22, 2012): Well, it seems that messages are getting same ids most of the time: > mysql> select count(id), message_id from sms_incoming group by message_id; > +-----------+------------+ > | count(id) | message_id | > +-----------+------------+ > | 258 | 0 | > | 1 | 153 | > | 3 | 17 | > | 1 | 171 | > | 16 | 214 | > | 1 | 23 | > | 1 | 233 | > | 1 | 236 | > | 1 | 241 | > | 1 | 245 | > | 1 | 250 | > | 1 | 257 | > | 1 | 263 | > | 1 | 264 | > | 1 | 265 | > | 16 | 28 | > | 3 | 30 | > | 1 | 43 | > | 11 | 49 | > | 2 | 53 | > | 38 | 56 | > | 15 | 57 | > | 3 | 58 | > | 1 | 59 | > | 1 | 74 | > | 1 | 96 | > | 1 | 97 | > | 1 | 98 | > +-----------+------------+ > 28 rows in set (0.00 sec) Why not just generate a hash of the message and use that as the ID?
Author
Owner

@eyedol commented on GitHub (Nov 23, 2012):

@agenttihirvinen probably a better idea than to rely on the system's message ID. Instead of generating a hash of the message, I would rather use the id field in the database. That is can be unique than the hash of the message. Imagine if the same number sends the same message?

<!-- gh-comment-id:10671889 --> @eyedol commented on GitHub (Nov 23, 2012): @agenttihirvinen probably a better idea than to rely on the system's message ID. Instead of generating a hash of the message, I would rather use the `id` field in the database. That is can be unique than the hash of the message. Imagine if the same number sends the same message?
Author
Owner

@mandric commented on GitHub (Nov 27, 2012):

I think that processSms.getId is a problem inside of handleSmsReceived. We really want to wait until the new sms is saved by android and then use the saved data to save the smsmessage model with known _id and thread_id. Then create a Pending message and fire off an event or task to process the pending message.

<!-- gh-comment-id:10743876 --> @mandric commented on GitHub (Nov 27, 2012): I think that `processSms.getId` is a problem inside of `handleSmsReceived`. We really want to wait until the new sms is saved by android and then use the saved data to save the smsmessage model with known `_id` and `thread_id`. Then create a Pending message and fire off an event or task to process the pending message.
Author
Owner

@ghost commented on GitHub (Nov 27, 2012):

@eyedol: The problem is, it is not unique. Most of the time 0 is returned, which is rather useless for identifying messages. It MUST be reliably unique to be of any use. Now I have to do hash checking on the server side to protect against reposts(messages comes in on the server side, gets processed, apparently connection times out occasionally or something before SMSSync gets the reply, and so sends the message again a few minutes later. Not very nice in cases where a message contains a command to forward it to 200 people. Especially if it happens five times in a row... ;)

<!-- gh-comment-id:10750081 --> @ghost commented on GitHub (Nov 27, 2012): @eyedol: The problem is, it is _not_ unique. Most of the time 0 is returned, which is rather useless for identifying messages. It MUST be reliably unique to be of any use. Now I have to do hash checking on the server side to protect against reposts(messages comes in on the server side, gets processed, apparently connection times out occasionally or something before SMSSync gets the reply, and so sends the message again a few minutes later. Not very nice in cases where a message contains a command to forward it to 200 people. Especially if it happens five times in a row... ;)
Author
Owner

@eyedol commented on GitHub (Feb 11, 2013):

@mandric I think using UUID.randomUUID().toString() which is in the Util package should be an ideal solution to get a unique ID. The current implementation of getting a unique ID isn't reliable. What do you think?

<!-- gh-comment-id:13394781 --> @eyedol commented on GitHub (Feb 11, 2013): @mandric I think using `UUID.randomUUID().toString()` which is in the [Util](http://developer.android.com/reference/java/util/UUID.html) package should be an ideal solution to get a unique ID. The current implementation of getting a unique ID isn't reliable. What do you think?
Author
Owner

@mandric commented on GitHub (Feb 11, 2013):

Sounds good.

Also I'm not sure if this relates, but I've had reports that some messages never get into the Android Messages inbox, so you get messages that have been processed by smssync but do not exist anywhere on the android device.

<!-- gh-comment-id:13396002 --> @mandric commented on GitHub (Feb 11, 2013): Sounds good. Also I'm not sure if this relates, but I've had reports that some messages never get into the Android Messages inbox, so you get messages that have been processed by smssync but do not exist anywhere on the android device.
Author
Owner

@eyedol commented on GitHub (Feb 11, 2013):

I haven't hit that yet.

I'm going to drop the _id column and replace that with message_id field to hold the UUID value.

<!-- gh-comment-id:13398794 --> @eyedol commented on GitHub (Feb 11, 2013): I haven't hit that yet. I'm going to drop the `_id` column and replace that with `message_id` field to hold the UUID value.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SMSSync#52
No description provided.