Replication Exception - Android to CouchDB - WARNING: Sync fn exception: SyntaxError: Unexpected token :


#1

Hello,

I am currently developping an app on Android, which create/update JSON doc and need continuous push/pull replication to CouchDB.

The goal is that the documents synced to DB have to be available for every users that i’ll get…so i tried to set the sync function that way (please confirm if i did it right :wink: )

I developed an API to auth my users and, in a second time, receive a session cookie from my CouchServer.
I successfully managed to code Android part with your tutorial, and some of your examples :wink:.

I launch CouchDBlite components and setup the replication at launch of my app, once i received the cookie.

Then i use " Map<String, Object> map = new HashMap<String, Object>() " and " document.putProperties(map)" to Update my document.
FYI, my variable “map” get his value from a json with the following code :

public static Map jsonToMap(String t) throws JSONException {

Map<String, Object> map = new HashMap<String, Object>();
JSONObject jObject = new JSONObject(t);
Iterator<?> keys = jObject.keys();

while( keys.hasNext() ){
    String key = (String)keys.next();
    String value = jObject.getString(key);
    map.put(key, value);

}

System.out.println("json : "+jObject);
System.out.println("map : "+map);
return map;

}

Until this point, everything works…

My problem is the following (if i understand correctly) :

I keep getting an exception during replication.
My document does’nt seem to replicate to the CouchServer, and revisions accumulate in local CouchDB lite instance (on the phone so).


I am rather new in coding and in CRUD operations on databases, so by advance, please adapt your response for a beginner :wink:


Sync Function :

    {
    "interface":":4984",
    "adminInterface":":4985",
    "log": ["CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Changes", "Changes+"],
    "databases":{
       "tm-db01":{
          "users": {
            "GUEST": {"disabled": true, "admin_channels": ["*"] }
          },
          "server":"http://xxxxxx:8091",
          "bucket":"default",
          "sync":
          `
             function(doc, oldDoc) {

                log("processing " + doc.userId);

              if (doc.isDeleted) {
                 // Only editors with write access can delete documents:
                 requireUser(oldDoc.owner);
             // Skip other validation because a deletion has no other properties:
                 return;
              }
              if (!doc.owner)
                 throw({forbidden: "Missing owner"});
              if (oldDoc && doc.owner != oldDoc.owner)
                 throw({forbidden: "Owner changed"});
              if (oldDoc == null) {
              // Only editors can create documents:
               // requireRole("role:editor");
              // The 'creator' property must match the user creating the document:
              requireUser(doc.owner)
              }
              else {
              // Only users in the existing doc's writers list can change a document:
              requireUser(oldDoc.owner);
             // The "creator" property is immutable:
                   if (doc.owner != oldDoc.owner) {
                      throw(forbidden: "Can't change owner");
                   }
              }
                     access(doc.owner,doc.type);
                     channel(doc.type); // "The document will be tagged by its category."
             // if (doc.type == "profile") {
              //   requireUser(oldDoc.owner);
               //  requireUser(doc.owner);
                 //requireRole("creators");
                // access(doc.owner,doc.type);
                 // channel(doc.type); // "The document will be tagged by its category."
                 //channel("readers_" + userId);
                 //access(*,doc.type);
          }
          `
      }
   }
}

Android Log :

07-03 15:11:58.222  26211-26563/com.mydomain.myapp E/CBLite﹕ Exception getting status from {error=500, id=FirstNameLastName2015_5_22_1434965641474, reason=Exception in JS sync function, status=500}  java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at com.couchbase.lite.replicator.ReplicationInternal.statusFromBulkDocsResponseItem(ReplicationInternal.java:1270)
 at com.couchbase.lite.replicator.PusherInternal$5.onCompletion(PusherInternal.java:497)
        

at com.couchbase.lite.support.RemoteRequestRetry$1.completed(RemoteRequestRetry.java:178)
            at com.couchbase.lite.support.RemoteRequestRetry$1.onCompletion(RemoteRequestRetry.java:189)
            at com.couchbase.lite.support.RemoteRequest.respondWithResult(RemoteRequest.java:310)
            at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:260)
            at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)

Gateway Logs (i removed some redundant CRUD+ revision calls) :

15:06:19.390177 FATAL: Error reading config file /opt/couchbase-sync-gateway/config.json: unexpected end of JSON input -- rest.ParseCommandLine() at config.go:294
15:09:41.441764 Enabling logging: [CRUD CRUD+ HTTP HTTP+ Access Cache Changes Changes+]
15:09:41.441851 ==== Couchbase Sync Gateway/1.0.4(34;04138fd) ====
15:09:41.441869 Configured Go to use all 2 CPUs; setenv GOMAXPROCS to override this
15:09:41.442464 Opening db /tm-db01 as bucket "default", pool "default", server <http://xxxxxxx:8091>
15:09:41.442535 Opening Couchbase database default on <http://xxxxxx:8091>
15:09:42.295977 Cache: Initialized changeCache with nextSequence=#110
15:09:42.304907 **NOTE:** "tm-db01"'s sync function has changed. The new function may assign different channels to documents, or permissions to users. You may want to re-sync the database to update these.
15:09:42.307980     Reset guest user to config
15:09:42.308025 Starting admin server on :4985
15:09:42.313808 Starting server on :4984 ...

15:10:09.582296 HTTP:  #001: POST /mydb/_resync  (ADMIN)
15:10:09.582786 HTTP: #001:     --> 404 no such database "mydb"  (0.8 ms)
15:10:18.579374 HTTP:  #002: POST /tm-db01/_resync  (ADMIN)
15:10:18.579455 Recomputing document channels...

2015/07/03 15:10:20 go-couchbase: call to ViewCustom("sync_housekeeping", "import") in github.com/couchbaselabs/sync_gateway/base.couchbaseBucket.View took 2.236308885s
15:10:20.818818 Re-running sync function on all 0 documents...
15:10:20.818933 Finished re-running sync function; 0 docs changed
15:10:20.819043 HTTP+: #002:     --> 200   (2239.7 ms)
15:11:32.162919 HTTP:  #003: POST /tm-db01/_session  (ADMIN)
15:11:32.189410 HTTP+: #003:     --> 200   (26.5 ms)
15:11:33.610953 HTTP:  #004: GET /tm-db01/_local/0878c48c880c87bf44b100ead3c6c8c6c5b0066f  (as FirstNameLastName2015_5_22_1434965641474)
15:11:33.611557 HTTP:  #005: GET /tm-db01/_local/344b68ba10039337403a044b13cbfa37e21fbcff  (as FirstNameLastName2015_5_22_1434965641474)
15:11:33.612834 HTTP+: #005:     --> 200   (3.2 ms)
15:11:33.617580 HTTP: #004:     --> 404 missing  (9.6 ms)
15:11:33.818072 HTTP:  #006: POST /tm-db01/_changes  (as FirstNameLastName2015_5_22_1434965641474)
15:11:33.818781 Changes: MultiChangesFeed({*}, {Since:0 Limit:0 Conflicts:true IncludeDocs:false Wait:false Continuous:false Terminator:0xc2101d04e0}) ...   (to FirstNameLastName2015_5_22_1434965641474)
15:11:33.820094 Changes+: MultiChangesFeed: channels expand to channels.TimedSet{"!":0x1} ...   (to FirstNameLastName2015_5_22_1434965641474)
15:11:33.820434 Cache: getCachedChanges("!", {0 0}) --> 0 changes valid from #111
15:11:33.820486 Cache:   Querying 'channels' view for "!" (start=#1, end=#111, limit=0)


2015/07/03 15:11:34 go-couchbase: call to ViewCustom("sync_gateway", "channels") in github.com/couchbaselabs/sync_gateway/base.couchbaseBucket.ViewCustom took 370.626577ms
15:11:34.191577 Cache:     Got no rows from view for "!"
15:11:34.191864 Cache: GetChangesInChannel("!") --> 0 rows
15:11:34.191982 Changes+: MultiChangesFeed sending &{Seq:84 ID:_user/FirstNameLastName2015_5_22_1434965641474 Deleted:false Removed:{} Doc:map[] Changes:[] branched:false}   (to FirstNameLastName2015_5_22_1434965641474)
15:11:34.192016 Changes: MultiChangesFeed done   (to FirstNameLastName2015_5_22_1434965641474)
15:11:34.192101 HTTP+: #006:     --> 200 OK  (0.0 ms)
15:11:34.377310 HTTP:  #007: POST /tm-db01/_changes  (as FirstNameLastName2015_5_22_1434965641474)
15:11:34.377428 Changes: MultiChangesFeed({*}, {Since:84 Limit:50 Conflicts:true IncludeDocs:false Wait:true Continuous:false Terminator:0xc2101d0a80}) ...   (to FirstNameLastName2015_5_22_1434965641474)
15:11:34.377570 Changes+: MultiChangesFeed: channels expand to channels.TimedSet{"!":0x1} ...   (to FirstNameLastName2015_5_22_1434965641474)
15:11:34.377752 Cache: getCachedChanges("!", {0 84}) --> 0 changes valid from #1
15:11:34.377785 Changes+: MultiChangesFeed waiting...   (to FirstNameLastName2015_5_22_1434965641474)
15:11:34.377835 Changes+: Waiting for "default"'s count to pass 0
15:11:34.619421 HTTP:  #008: POST /tm-db01/_revs_diff  (as FirstNameLastName2015_5_22_1434965641474)
15:11:34.620296 HTTP+: #008:     --> 200   (3.6 ms)
15:11:35.586352 HTTP:  #009: POST /tm-db01/_bulk_docs  (as FirstNameLastName2015_5_22_1434965641474)
15:11:36.782769 HTTP:  #010: POST /tm-db01/_revs_diff  (as FirstNameLastName2015_5_22_1434965641474)
15:11:36.784064 HTTP+: #010:     --> 200   (4.0 ms)
15:11:37.468666 HTTP:  #011: POST /tm-db01/_revs_diff  (as FirstNameLastName2015_5_22_1434965641474)
15:11:37.469621 HTTP+: #011:     --> 200   (3.1 ms)
15:11:37.687752 HTTP:  #012: POST /tm-db01/_bulk_docs  (as FirstNameLastName2015_5_22_1434965641474)
15:11:38.537379 HTTP:  #013: POST /tm-db01/_bulk_docs  (as FirstNameLastName2015_5_22_1434965641474)
15:11:40.507068 CRUD+: Invoking sync on doc "FirstNameLastName2015_5_22_1434965641474" rev 3613-9878a3ed68a832859d653e53d0e70059
15:11:40.508398 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3612-5bb655b5d7e3b8da5296c529a8b6dc39"
15:11:40.509228 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3611-042174a914f310f98bbd66bd44c988dc"
15:11:40.509859 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3610-042174a914f310f98bbd66bd44c988dc"
15:11:40.510453 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3609-6a07db0213d63c880918cab291395fed"
3465-d73ee67fd07b3858acd5c6b1a41d12fa"
15:11:40.692912 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3464-d73ee67fd07b3858acd5c6b1a41d12fa"
15:11:40.693971 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3463-127741abb8ac9be1baebeb80ef65c001"
15:11:40.695165 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3462-127741abb8ac9be1baebeb80ef65c001"
15:11:40.696254 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3461-26a2e80e528a89611df1999b75ef1f51"
15:11:40.696902 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3460-26a2e80e528a89611df1999b75ef1f51"
15:11:40.698853 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3459-b1935f635e02a3648e4c87653f7fe2e1"
15:11:40.699575 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3458-b1935f635e02a3648e4c87653f7fe2e1"
15:11:40.701499 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3457-3d71d376ab415c9333067631a6e27fdd"
15:11:40.704503 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3456-3d71d376ab415c9333067631a6e27fdd"
15:11:40.705367 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3455-0abe336bb987eaf89ae267176e628077"
15:11:40.705991 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3454-0abe336bb987eaf89ae267176e628077"
15:11:40.706917 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3453-be5aef627d5c6afd562f2defb6ac71e4"
15:11:40.707547 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3452-be5aef627d5c6afd562f2defb6ac71e4"
15:11:40.708399 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3451-6000c7f6baa3b052b02d9e92fa2c8b83"
15:11:40.709267 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3450-6000c7f6baa3b052b02d9e92fa2c8b83"
15:11:40.710072 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3449-1349238f50b4b768ce9a7b1512fda22b"
15:11:40.710908 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3448-1349238f50b4b768ce9a7b1512fda22b"
"FirstNameLastName2015_5_22_1434965641474" / "3322-bb68fbd15af28db8cb43055d0f408ab6"
d3041cfe207d500d217775a482566c7f"


15:11:44.022454 WARNING: Sync fn exception: SyntaxError: Unexpected token : (line 30); doc = map[_rev:3613-9878a3ed68a832859d653e53d0e70059 _id:FirstNameLastName2015_5_22_1434965641474 _revisions:map[start:%!s(float64=3613) ids:[9878a3ed68a832859d653e53d0e70059 5bb655b5d7e3b8da5296c529a8b6dc39 042174a914f310f98bbd66bd44c988dc 042174a914f310f98bbd66bd44c988dc 6a07db0213d63c880918cab291395fed 135ae8a28c02eac27732afff9d209df2 b1a119867e09e013e9f2e04411f4291b 68e8920aa1caf6468c1c87f445d5bd8f 29a6a39a0431502deefa80ac6f3a49d4 29a6a39a0431502deefa80ac6f3a49d4 526a661dd2627cb440b0f0fbf08ba6ae 526a661dd2627cb440b0f0fbf08ba6ae 4a02a553396ce8257fde9cd6b012cf52 4a02a553396ce8257fde9cd6b012cf52 9700a65f38e4fe2f010e39ec6d089a91 9700a65f38e4fe2f010e39ec6d089a91 fbcf84c502875c66c16c4e7dd2933f91 fbcf84c502875c66c16c4e7dd2933f91 5c2b416d508e80db3fa1c01d42fdc2a2 5c2b416d508e80db3fa1c01d42fdc2a2 4f4dd477923b84ed40dcabd6b1732e67 4f4dd477923b84ed40dcabd6b1732e67 b2c787fa64c14a4562b65df076c6bc4d b2c787fa64c14a4562b65df076c6bc4d 79d06be9a87ed281fda78c708ae75a40 b58b412b9ac2b26f54e44d8e585026c7 0326650974a2d1a7926a88f5d28f18d7 0326650974a2d1a7926a88f5d28f18d7 64ffe7a557bf031e4653e6c0e0551340 64ffe7a557bf031e4653e6c0e0551340 7110ee3f7e8107d6ea5b71bd48fe7f81 7110ee3f7e8107d6ea5b71bd48fe7f81 d641495623f831c4c3da3500f05ad4a3 d641495623f831c4c3da3500f05ad4a3 d3041cfe207d500d217775a482566c7f]] _deleted:%!s(bool=true)] -- db.(*Database).getChannelsAndAccess() at crud.go:715
15:11:44.022796     BulkDocs: Doc "FirstNameLastName2015_5_22_1434965641474" --> 500 Exception in JS sync function (500 Exception in JS sync function)
15:11:44.022860 HTTP+: #009:     --> 201   (8439.3 ms)
15:11:44.186628 HTTP:  #018: PUT /tm-db01/_local/344b68ba10039337403a044b13cbfa37e21fbcff  (as FirstNameLastName2015_5_22_1434965641474)
15:11:44.188695 HTTP+: #018:     --> 201   (4.0 ms)
15:11:44.889940 CRUD+: Invoking sync on doc "FirstNameLastName2015_5_22_1434965641474" rev 3614-9f0927fc4afec4653ed12f46d331e213
15:11:44.890825 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3613-9878a3ed68a832859d653e53d0e70059"
15:11:44.891850 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3612-5bb655b5d7e3b8da5296c529a8b6dc39"
15:11:44.892490 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3611-042174a914f310f98bbd66bd44c988dc"
15:11:44.897168 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3610-042174a914f310f98bbd66bd44c988dc"
15:11:44.898112 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3609-6a07db0213d63c880918cab291395fed"
15:11:44.898775 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3608-135ae8a28c02eac27732afff9d209df2"
15:11:44.899635 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3607-b1a119867e09e013e9f2e04411f4291b"
15:11:44.900364 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3606-68e8920aa1caf6468c1c87f445d5bd8f"
15:11:44.901291 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3605-29a6a39a0431502deefa80ac6f3a49d4"
15:11:44.902324 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3604-29a6a39a0431502deefa80ac6f3a49d4"
15:11:44.902932 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3603-526a661dd2627cb440b0f0fbf08ba6ae"
15:11:44.903473 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3602-526a661dd2627cb440b0f0fbf08ba6ae"
15:11:44.904031 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3601-a12b2dc0e66c0d595758aa8ff8dd3ac4"
15:11:44.904677 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3600-a12b2dc0e66c0d595758aa8ff8dd3ac4"
15:11:44.905254 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3599-f5e73c7219b678a7b299a5e1b28be52e"
15:11:44.905870 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3598-f5e73c7219b678a7b299a5e1b28be52e"
15:11:44.906577 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3597-8a68e65a3c8f6ac3d30573e41db6a3b2"
15:11:44.907175 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3596-8a68e65a3c8f6ac3d30573e41db6a3b2"
15:11:44.907849 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3595-6fa81b29312a3d446792c261ac5f2ab8"
15:11:44.908421 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3594-6fa81b29312a3d446792c261ac5f2ab8"
15:11:44.908937 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3593-9afbc1574180567cd45acf29a15f1086"
15:11:44.909481 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3592-9afbc1574180567cd45acf29a15f1086"
15:11:44.910025 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3591-28f840081dc0832092ca226a1661b05b"
15:11:44.910522 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "3590-28f840081dc0832092ca226a1661b05b"
"FirstNameLastName2015_5_22_1434965641474" / "1946-c48a4fa07f03b871d90e749d4d260892"
15:11:50.143890 WARNING: Sync fn exception: SyntaxError: Unexpected token : (line 30); doc = map[_rev:3614-9f0927fc4afec4653ed12f46d331e213 _id:FirstNameLastName2015_5_22_1434965641474 _revisions:map[start:%!s(float64=3614) ids:[9f0927fc4afec4653ed12f46d331e213 9878a3ed68a832859d653e53d0e70059 5bb655b5d7e3b8da5296c529a8b6dc39 042174a914f310f98bbd66bd44c988dc 042174a914f310f98bbd66bd44c988dc 6a07db0213d63c880918cab291395fed 135ae8a28c02eac27732afff9d209df2 b1a119867e09e013e9f2e04411f4291b 68e8920aa1caf6468c1c87f445d5bd8f 29a6a39a0431502deefa80ac6f3a49d4 29a6a39a0431502deefa80ac6f3a49d4 526a661dd2627cb440b0f0fbf08ba6ae 526a661dd2627cb440b0f0fbf08ba6ae a12b2dc0e66c0d595758aa8ff8dd3ac4 a12b2dc0e66c0d595758aa8ff8dd3ac4 f5e73c7219b678a7b299a5e1b28be52e f5e73c7219b678a7b299a5e1b28be52e 8a68e65a3c8f6ac3d30573e41db6a3b2 8a68e65a3c8f6ac3d30573e41db6a3b2 6fa81b29312a3d446792c261ac5f2ab8 6fa81b29312a3d446792c261ac5f2ab8 9afbc1574180567cd45acf29a15f1086 9afbc1574180567cd45acf29a15f1086 28f840081dc0832092ca226a1661b05b 28f840081dc0832092ca226a1661b05b 15332a73b4d7a5514d0065c5f9745325 35309a10012ab5a30e7d1b6223a2a2da 35309a10012ab5a30e7d1b6223a2a2da d97d9e8f8c03fac029a4c8d77aa8ee76 d97d9e8f8c03fac029a4c8d77aa8ee76 ff01cd2840bbbe040c88de7b25be2a3b ff01cd2840bbbe040c88de7b25be2a3b b7319a0fdf23112c0fb608a9a273a95d b7319a0fdf23112c0fb608a9a273a95d 8f11c1c8fed80f9cc940adc9262f4433 8f11c1c8fed80f9cc940adc9262f4433 6d3f9526a7d4758c1c131d9050caa46a 6d3f9526a7d4758c1c131d9050caa46a e0e1697c8258ea8eeef088194666fb9e e0e1697c8258ea8eeef088194666fb9e 5e0803c6c9f7b7c71aff14cf51fdd69e 5e0803c6c9f7b7c71aff14cf51fdd69e a9f83a9a3906e5a0e230bc8e3625086a a9f83a9a3906e5a0e230bc8e3625086a 1206b97d7fff5924277d85bdafe2e91c 1206b97d7fff5924277d85bdafe2e91c 46d5b266695350406650e95a8580336e 46d5b266695350406650e95a8580336e 4439fde9c6b09214c542ac470601618f 4439fde9c6b09214c542ac470601618f b62455744dab4255691d66a5425aa116 b62455744dab4255691d66a5425aa116 96784c972e8073f26d9bbf892675d9ce 96784c972e8073f26d9bbf892675d9ce 9667f19e03c63076f08bfa041755b1b8 9667f19e03c63076f08bfa041755b1b8 00fae2c8ab1309a476df02bd92e46d8b 00fae2c8ab1309a476df02bd92e46d8b 9d36794474caa3a0df6fd476e7aee29d 9d36794474caa3a0df6fd476e7aee29d bb69e80da7e94ba1b6f84f28c64f1998 bb69e80da7e94ba1b6f84f28c64f1998 adfd47235a0fa42bd93ae84303e54068 adfd47235a0fa42bd93ae84303e54068 c82c54d1afbb544cb69991a1b1c08f2f c82c54d1afbb544cb69991a1b1c08f2f 5c4566204e7b2d09b7d01c44a5dc3cac 5c4566204e7b2d09b7d01c44a5dc3cac cda45c81d822ffe0df17444a84b67c75 cda45c81d822ffe0df17444a84b67c75 28b64b0c709a98406fe73d13921db688 28b64b0c709a98406fe73d13921db688 68badf92b2a6154abe76e3243a4d6b77 68badf92b2a6154abe76e3243a4d6b77 5ceefe6f8b84204003b9dc182883aad5 5ceefe6f8b84204003b9dc182883aad5 5fb89555ff2791b31a110fbd3be7ab76 5fb89555ff2791b31a110fbd3be7ab76 9d3c7736ea1b8cff49ced68035aca8a5 9d3c7736ea1b8cff49ced68035aca8a5 a822db78bb87d17f39d6e3535fa217e5 a822db78bb87d17f39d6e3535fa217e5 dc1a6d98d722714f2faf711fb0d0779b dc1a6d98d722714f2faf711fb0d0779b 04d0909a87e79e8c7785fc3205d1d48b 04d0909a87e79e8c7785fc3205d1d48b be6b4e6ef7c79cbb914958f9237eed56 be6b4e6ef7c79cbb914958f9237eed56 ce77e28347c84486a328b6ffc06ee22f ce77e28347c84486a328b6ffc06ee22f d6fd16ed631d2d15468b90290bb5a72f d6fd16ed631d2d15468b90290bb5a72f ee3ecdb33cfb5489b8c1faf811aed021 ee3ecdb33cfb5489b8c1faf811aed021 cafefe439abc85f4932ddbfd4687384a cafefe439abc85f4932ddbfd4687384a 4a02a553396ce8257fde9cd6b012cf52 9700a65f38e4fe2f010e39ec6d089a91 9700a65f38e4fe2f010e39ec6d089a91 fbcf84c502875c66c16c4e7dd2933f91 fbcf84c502875c66c16c4e7dd2933f91 5c2b416d508e80db3fa1c01d42fdc2a2 5c2b416d508e80db3fa1c01d42fdc2a2 4f4dd477923b84ed40dcabd6b1732e67 4f4dd477923b84ed40dcabd6b1732e67 b2c787fa64c14a4562b65df076c6bc4d b2c787fa64c14a4562b65df076c6bc4d 79d06be9a87ed281fda78c708ae75a40 b58b412b9ac2b26f54e44d8e585026c7 0326650974a2d1a7926a88f5d28f18d7 0326650974a2d1a7926a88f5d28f18d7 64ffe7a557bf031e4653e6c0e0551340 64ffe7a557bf031e4653e6c0e0551340 7110ee3f7e8107d6ea5b71bd48fe7f81 7110ee3f7e8107d6ea5b71bd48fe7f81 d641495623f831c4c3da3500f05ad4a3 d641495623f831c4c3da3500f05ad4a3 d3041cfe207d500d217775a482566c7f]] location:Location[fused 43.599135,3.900733 acc=30 et=+5d20h45m36s702ms] lastUpdateTime:3:11:18 PM] -- db.(*Database).getChannelsAndAccess() at crud.go:715
15:11:50.144233     BulkDocs: Doc "FirstNameLastName2015_5_22_1434965641474" --> 500 Exception in JS sync function (500 Exception in JS sync function)
15:11:50.144284 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1945-995884e630fb15883d828af2f076db3f"
15:11:50.144303 HTTP+: #012:     --> 201   (12466.4 ms)
15:11:50.145241 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1944-995884e630fb15883d828af2f076db3f"
15:11:50.145930 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1943-b1c6232c66b13f86755eabab5743aef0"
15:11:50.146617 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1942-b1c6232c66b13f86755eabab5743aef0"
15:11:50.147191 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1941-3a0e7ace25b8dc669f065a57df8af3e2"
15:11:50.147674 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1940-3a0e7ace25b8dc669f065a57df8af3e2"
15:11:50.148322 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1939-542a7d948eaa26240f9f4f9bc1a44476"
15:11:50.148903 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1938-542a7d948eaa26240f9f4f9bc1a44476"
15:11:50.149407 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1937-938d43a2b846e372fea74df7e8dd4199"
revision "FirstNameLastName2015_5_22_1434965641474" / "1800-184241e6f848bdb7781d909c57ab1bff"
15:11:53.014201 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "2214-b88d37900e38004ff439324507c09dc1"
15:11:53.014418 WARNING: Sync fn exception: SyntaxError: Unexpected token : (line 30); doc = map[_rev:3615-9f0927fc4afec4653ed12f46d331e213 _id:FirstNameLastName2015_5_22_1434965641474 _revisions:map[start:%!s(float64=3615) ids:[9f0927fc4afec4653ed12f46d331e213 9f0927fc4afec4653ed12f46d331e213 9878a3ed68a832859d653e53d0e70059 5bb655b5d7e3b8da5296c529a8b6dc39 042174a914f310f98bbd66bd44c988dc 042174a914f310f98bbd66bd44c988dc 6a07db0213d63c880918cab291395fed 135ae8a28c02eac27732afff9d209df2 b1a119867e09e013e9f2e04411f4291b 68e8920aa1caf6468c1c87f445d5bd8f 29a6a39a0431502deefa80ac6f3a49d4 29a6a39a0431502deefa80ac6f3a49d4 526a661dd2627cb440b0f0fbf08ba6ae 526a661dd2627cb440b0f0fbf08ba6ae a12b2dc0e66c0d595758aa8ff8dd3ac4 a12b2dc0e66c0d595758aa8ff8dd3ac4 f5e73c7219b678a7b299a5e1b28be52e f5e73c7219b678a7b299a5e1b28be52e 8a68e65a3c8f6ac3d30573e41db6a3b2 8a68e65a3c8f6ac3d30573e41db6a3b2 6fa81b29312a3d446792c261ac5f2ab8 6fa81b29312a3d446792c261ac5f2ab8 9afbc1574180567cd45acf29a15f1086 9afbc1574180567cd45acf29a15f1086 28f840081dc0832092ca226a1661b05b 28f840081dc0832092ca226a1661b05b 15332a73b4d7a5514d0065c5f9745325 15332a73b4d7a5514d0065c5f9745325 1ba3930d8720ea6bb7a55ed0956d8aab 1ba3930d8720ea6bb7a55ed0956d8aab 4429f45f70393e817f38f41bd03c2fe4 4429f45f70393e817f38f41bd03c2fe4 0eae4899d80fd48a78f1304ef68596ae cbf5a4b77a6568a330cf62e8b83247b4 f06cd44b7054966eb5fdf5a0dd51f7f7 f06cd44b7054966eb5fdf5a0dd51f7f7 92f62f3e6474df3307b55273f42ad87b 92f62f3e6474df3307b55273f42ad87b d2c15929e89bab9530410306e120863a d2c15929e89bab9530410306e120863a d3a9c298b786e4e4f4566e245657f606 d3a9c298b786e4e4f4566e245657f606 5c2b416d508e80db3fa1c01d42fdc2a2 5c2b416d508e80db3fa1c01d42fdc2a2 4f4dd477923b84ed40dcabd6b1732e67 4f4dd477923b84ed40dcabd6b1732e67 b2c787fa64c14a4562b65df076c6bc4d b2c787fa64c14a4562b65df076c6bc4d 79d06be9a87ed281fda78c708ae75a40 b58b412b9ac2b26f54e44d8e585026c7 0326650974a2d1a7926a88f5d28f18d7 0326650974a2d1a7926a88f5d28f18d7 64ffe7a557bf031e4653e6c0e0551340 64ffe7a557bf031e4653e6c0e0551340 7110ee3f7e8107d6ea5b71bd48fe7f81 7110ee3f7e8107d6ea5b71bd48fe7f81 d641495623f831c4c3da3500f05ad4a3 d641495623f831c4c3da3500f05ad4a3 d3041cfe207d500d217775a482566c7f]] location:Location[fused 43.599135,3.900733 acc=30 et=+5d20h45m36s702ms] lastUpdateTime:3:11:18 PM] -- db.(*Database).getChannelsAndAccess() at crud.go:715
15:11:53.014485 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1799-6daa8b979e06afbafbbf4753ca14379a"
15:11:53.014810     BulkDocs: Doc "FirstNameLastName2015_5_22_1434965641474" --> 500 Exception in JS sync function (500 Exception in JS sync function)
15:11:53.014663 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "2213-97d7bd61f10e4492d81159e0e1805597"
15:11:53.014966 HTTP+: #013:     --> 201   (14479.8 ms)
15:11:53.015391 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1798-6daa8b979e06afbafbbf4753ca14379a"
15:11:53.015448 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "2212-97d7bd61f10e4492d81159e0e1805597"
15:11:53.015903 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1797-95da0145b97626a8d75ba7896afd8919"
15:11:53.016075 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "2211-64a0505de0b011426d79a8685b41543f"
15:11:53.016441 CRUD+: No old revision 
15:11:53.793230 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1787-0266ab6ce9766cb3def89602ff2eb348"
15:11:53.793338 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1358-0212be9fbd4e2ca7d7f54299a07f709a"
15:11:53.794065 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1357-159db43556e5f083030b33810c619434"
15:11:53.795180 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1356-159db43556e5f083030b33810c619434"
15:11:53.795261 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1786-0266ab6ce9766cb3def89602ff2eb348"
15:11:53.795894 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1355-2d9a314228a8a20104b14bd65d11a288"
15:11:53.795961 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1785-3f69bb3291051415735a7ac17e846b61"
15:11:53.796622 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1784-3f69bb3291051415735a7ac17e846b61"
15:11:53.796678 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1354-2d9a314228a8a20104b14bd65d11a288"
15:11:53.797353 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1353-5b22c249d4e4a8d5baa49651e878e7fe"
15:11:53.797465 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1783-e6b04b4c1f9cac26333685a8ba6236ed"
15:11:53.798123 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1782-e6b04b4c1f9cac26333685a8ba6236ed"
15:11:53.798128 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1352-5b22c249d4e4a8d5baa49651e878e7fe"
15:11:53.798639 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1781-1f74f0f3ef8a6f7f32200d09ea9686df"
15:11:53.798741 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1351-7ced7f03220151855118289c4f49fd65"
15:11:53.799284 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1350-7ced7f03220151855118289c4f49fd65"
15:11:53.799751 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1780-1f74f0f3ef8a6f7f32200d09ea9686df"
15:11:53.800079 CRUD+: No old revision "FirstNameLastName2015_5_22_1434965641474" / "1349-645d85f857ccabef1af4615cc4512971"

#3

OK, I’m guessing the FATAL error was from a previous run of the Gateway and then you corrected the JSON error and restarted it. But down below in the SG logs there’s a clear warning about an exception thrown in the sync function:

The reason I looked through the SG logs for this, is because the Java exception in the client says it occurred due to an exception in the server-side sync function:

Always carefully read the error messages you receive.


#4

Thanks a lot for your input !

That’s right.

That’s right :smile: . I had noticed this…though, i have no idea what causes this exception and so, the way to fix it.

Any idea ?


#5

“Unexpected token” is a JS syntax error.


#6

So, if i understand correctly…there is invalid token, line 30 of my “config.json” file on the SG ?
I don’t see it…


#7

No, line 30 of the sync function. It’s this:

   throw (forbidden: "Can't change owner");

There should be curly braces inside the parentheses. (Actually IIRC the parentheses are optional; throw is not a function.)


#8

Thanks for your help…

The issue was coming from the semi-column.
I removed it and no more exception :smile:
Only codes 200 and 201 in my logs !! :sunny:

I wouldn’t have think of that alone… I’ve been re-writing full block of codes, sync function and even flushed DBs.
At final, It is always the simpliest details that got me stuck.