Sync the two tables when one fails ?.


I have a mobile app that has a local transaction table and a local image table.  An Id number is given to the transaction record when created.  When a picture is taken for the record it is stored it is given an id of a nullidentifier and the transaction identifier generated when the parent record was created so can be a one to many relationship of transaction to images.  I have consolidated this all into one server action for an offline data sync

My issues is when I sync sometimes the connection will time out, no idea why (BTW is there someway to find out).  I have set the offline datasync configuration to retry on error.  When it does this I sometime get an primary key insert error on the server side because the all records are sent again.

Is there any way I can keep this from happening? 





For this "My issues is when I sync sometimes the connection will time out" it's possible that the data you send is very big (MB) so the timeout is triggered. My suggestion is for image, you compress/resize it first before save to local and send to server (

For "no idea why (BTW is there someway to find out)" you can check on the service center - monitoring, on errors and screen requests. Also if you tested this on android, using logcat will help show log from the android device (



Hi Jacky Joy,

As Toto mentioned some of the references;  I would like to mention some other practices for the same.

Considering you are storing the images as a binary & with 1-M mapping:

  • Increase the ServrRequestTimeout [ Either of that Module or the respective Sync Action]
  • On the Server-Side; which is responsible for inserting i.e saving the data received from Mobile; you can use the CreateOrUpdate Action instead of Create.
    For instance, if the DataSync gets failed &Mobile resend the same items again to the server; then it should override it rather creating a new one. This will solve your Duplicate primary-key issue.
  • If in case the payload is heavy then you can send a limited number of records & maintain the index to send further records with the new call.
  • For the Image Compression; its your call whether to apply or not :)

    Hope it helps;

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.