I need some help using Cognito Sync Manager synchronize feature.
The context : I want to store 2 values (key and user) in a cognito dataset. The key value change very often (at each connection) when the user is initialized once and then remains the same.
As it is shown in the documentation, I have called my credentials, instantiated a new CognitoSyncManager, opened/created my dataset, put data in it and finaly synchronized my dataset.
At the first synchronization (when dataset is created) there is no problem, but at the second it begins to fail (409 Conflict error).
Message returned by cognito : "{"message":"Current SyncCount for: user is: 1 not: 0"}".
It seems that synchronizing a dataset where some values change, but one or more kept the same values cause synchronization conflict that leads to failure after 4 attempts.
My synchronization function :
function synchronize(dataset, callback) {
dataset.synchronize({
onSuccess: function(dataset, newRecords) {
console.log("Dataset has been synchronized !");
return;
},
onFailure: function(err) {
console.error("Unable to synchronize dataset.")
console.log(err);
return;
},
onConflict: function(dataset, conflicts, callback) {
var resolved = [];
for(var i = 0; i < conflicts.length; i++)
{
resolved.push(conflicts[i].resolveWithLocalRecord());
}
dataset.resolve(resolved, function(err, data) {
if(err) { console.log(err); return callback(false); }
console.log("Conflict resolved with local record.");
return callback(true);
});
},
onDatasetDeleted: function(dataset, datasetName, callback) {
console.log("Dataset deleted.");
return callback(true);
},
onDatasetMerged: function(dataset, datasetNames) {
console.log("Dataset merged.");
return callback(false);
}
});
}
Is this an issue with the cognitoSyncManager or did I do something wrong ?
Thank you in advance for you help.
With best regards,
Michael
Hi,
I need some help using Cognito Sync Manager synchronize feature. The context : I want to store 2 values (key and user) in a cognito dataset. The key value change very often (at each connection) when the user is initialized once and then remains the same.
As it is shown in the documentation, I have called my credentials, instantiated a new CognitoSyncManager, opened/created my dataset, put data in it and finaly synchronized my dataset.
At the first synchronization (when dataset is created) there is no problem, but at the second it begins to fail (409 Conflict error). Message returned by cognito : "{"message":"Current SyncCount for: user is: 1 not: 0"}".
It seems that synchronizing a dataset where some values change, but one or more kept the same values cause synchronization conflict that leads to failure after 4 attempts. My synchronization function :
Is this an issue with the cognitoSyncManager or did I do something wrong ?
Thank you in advance for you help. With best regards, Michael