Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO2.11011: error while submitting changes to remote collection #25

Closed
shadialian opened this issue Sep 6, 2017 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@shadialian
Copy link

I am trying to use nitrite database with a project I am working on and it needs to be connected to the datagate server.

I set up the users and clients when syncing starts it throwing this error.
on the client side
org.dizitart.no2.exceptions.SyncException: NO2.11011: error while submitting changes to remote collection

on the server side
org.dizitart.no2.exceptions.InvalidOperationException: NO2.3009: document id is an auto generated value and can not be 771985705443479845

and I have a question. do I need to create the collection manually on mongo.

Thanks for help

@anidotnet
Copy link
Contributor

I strongly suggest you consider the reference documentation first - http://www.dizitart.org/nitrite-database/doc/2.0.0/index.html#replication

You don't need to manually create the collections in mongo. It will be created by this line from client

DataGateSyncTemplate syncTemplate
        = new DataGateSyncTemplate(dataGateClient, "remote-collection@userId");

Here "remote-collection@userId" is the collection name that will be created in mongo by datagate.

@shadialian
Copy link
Author

shadialian commented Sep 6, 2017

I've been throw the documentation many times but nothing.

this is my client code.

DataGateClient dataGateClient = new DataGateClient("http://localhost:9090")
        .withAuth("shadi", "123456")
        .withUserAgent(userAgent);
DataGateSyncTemplate syncTemplate
        = new DataGateSyncTemplate(dataGateClient, "test-collection@shadi");
NitriteCollection collection = DB.getCollection("test");      
SyncHandle syncHandle = Replicator.of(DB)
        .forLocal(collection)
        // a DataGate sync template implementation
        .withSyncTemplate(syncTemplate)
        // replication attempt delay of 1 sec
        .delay(timeSpan(1, TimeUnit.SECONDS))
        // both-way replication
        .ofType(ReplicationType.BOTH_WAY)
        // sync event listener
        .withListener(new SyncEventListener() {
            @Override
            public void onSyncEvent(SyncEventData eventInfo) {
              System.out.println("data is synced" + eventInfo.getError());
            }
        })
        .configure();
syncHandle.startSync();
Document doc = createDocument("firstName", "John")
     .put("lastName", "Doe")
     .put("birthDay", new Date())
     //.put("data", new byte[] {1, 2, 3})
     //.put("fruits", new ArrayList<String>() {{ add("apple"); add("orange"); }})
     .put("note", "a quick brown fox jump over the lazy dog");
collection.insert(doc);
DB.commit();
DB.close();

my client application is throwing this exception

data is syncedorg.dizitart.no2.exceptions.SyncException: NO2.11011: error while submitting changes to remote collection
[ScheduledWorker.NO₂] ERROR org.dizitart.no2.sync.DataGateSyncTemplate - Remote error while submitting change feed to remote
org.dizitart.no2.exceptions.SyncException: NO2.11017: HTTP/1.1 400 Bad Request
at org.dizitart.no2.sync.DataGateSyncTemplate.change(DataGateSyncTemplate.java:99)
at org.dizitart.no2.sync.SyncService.mergeChanges(SyncService.java:233)
at org.dizitart.no2.sync.SyncService.mergeChanges(SyncService.java:143)
at org.dizitart.no2.sync.CollectionReplicator.run(CollectionReplicator.java:63)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

the server is throwing this exception

2017-09-06 13:41:35.735 ERROR 5847 --- [qtp914356853-15] o.d.n.d.advices.DataGateApiErrorHandler : DataGate HTTP Error

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: NO2.3009: document id is an auto generated value and can not be 771985644632835459; nested exception is com.fasterxml.jackson.databind.JsonMappingException: NO2.3009: document id is an auto generated value and can not be 771985644632835459 (through reference chain: org.dizitart.no2.sync.data.ChangeFeed["modifiedDocuments"]->java.util.ArrayList[0]->org.dizitart.no2.Document["_id"])

please if you any idea where would look for a solution

@anidotnet anidotnet reopened this Sep 6, 2017
@anidotnet
Copy link
Contributor

anidotnet commented Sep 6, 2017

I'll take a look into it tomorrow. Meantime can you also go through one of the datagate junit tests? That might give you an idea if you are doing anything wrong. Now is the night time for me here, so can't be of immediate help. This is the file you need to look at - https://github.com/dizitart/nitrite-database/blob/master/nitrite-datagate/src/test/java/org/dizitart/no2/datagate/DataGateSyncTest.java

@anidotnet
Copy link
Contributor

Sorry for the late reply, I was so caught up with my work.

Can you please remove the line - DB.close() from your code and test? The close() call will shutdown the sync thread and can cause unexpected result. Meantime, please look into the this test file - SyncIntegrationTest.java for properly initializing your sync code. And let me know if you still see any issue.

@anidotnet anidotnet self-assigned this Oct 10, 2017
@anidotnet anidotnet added the bug label Oct 10, 2017
@anidotnet anidotnet added this to the 2.0.1 milestone Oct 10, 2017
anidotnet added a commit that referenced this issue Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants