sqlite-sync / SQLite-sync.com

AMPLI-SYNC is a framework for synchronizing data between a Sqlite database and an MS SQL/MySQL/Oracle/PostgreSQL database. With this framework your application can work completely offline (Airplane Mode), then perform an automated Bidirectional Synchronization when an internet connection becomes available.
https://ampliapps.com/sqlite-sync/
BSD 3-Clause "New" or "Revised" License
326 stars 82 forks source link

Sending data failed #52

Closed supertom495 closed 3 years ago

supertom495 commented 3 years ago

The content object I send to Server:

"<?xml version=\"1.0\" encoding=\"utf-8\"?><SyncData xmlns=\"urn:sync-schema\"><tab n=\"MergeIdentity\"><ins></ins><upd></upd></tab><tab n=\"person\"><ins><r><PersonID><![CDATA[6]]></PersonID><LastName><![CDATA[g]]></LastName><FirstName><![CDATA[b]]></FirstName><RowId><![CDATA[null]]></RowId></r></ins><upd></upd></tab><delete></delete></SyncData>"

subscriber id: 642661417

The log I found in 'sync.log':

2020-10-19 14:05:40,948 INFO Receiving data from subscriber 642661417
2020-10-19 14:05:40,971 ERROR CommitChangesToDb() ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
2020-10-19 14:05:40,975 INFO Finished receiving data from subscriber 642661417
2020-10-19 14:05:41,235 INFO Getting changes for subscriber 1 and table MergeIdentity
2020-10-19 14:05:41,247 TRACE select distinct * from ( select  tb.*,1 as MergeContent_TableId,   1 as MergeContent_SubscriberId,  tb.RowId as MergeContent_RowId,  tb.RowVer as MergeContent_RowVer,  t.ChangeDate as MergeContent_ChangeDate, -1 as MergeContent_Action,   null as MergeContent_SyncId   from `MergeIdentity` tb left join `MergeIdentity` vw on tb.RowId=vw.RowId left join `MergeContent_MergeIdentity` t on vw.RowId=t.RowId and t.SubscriberId=1 where (t.RowVer<>tb.RowVer or t.RowId is null) and vw.SubscriberId=1  union all select  t.*,1 as MergeContent_TableId,   1 as MergeContent_SubscriberId,  m.RowId as MergeContent_RowId,  m.RowVer as MergeContent_RowVer,  m.ChangeDate as MergeContent_ChangeDate,   3 as MergeContent_Action,   null as MergeContent_SyncId   from `MergeContent_MergeIdentity` m left join `MergeIdentity` vw on m.RowId=vw.RowId and m.SubscriberId=1 and vw.SubscriberId=1  left join `MergeIdentity` t on vw.RowId=t.RowId  where vw.RowId is null  and m.SubscriberId=1  ) as mergeVw
2020-10-19 14:05:41,259 TRACE [ {
  "TableName" : "",
  "Records" : "",
  "QueryInsert" : "",
  "QueryUpdate" : "",
  "QueryDelete" : "",
  "TriggerInsert" : "",
  "TriggerUpdate" : "",
  "TriggerDelete" : "",
  "TriggerInsertDrop" : "",
  "TriggerUpdateDrop" : "",
  "TriggerDeleteDrop" : "",
  "SyncId" : -1,
  "SQLiteSyncVersion" : ""
} ]
2020-10-19 14:05:41,369 INFO Getting changes for subscriber 1 and table person
2020-10-19 14:05:41,381 TRACE select distinct * from ( select  tb.*,2 as MergeContent_TableId,   1 as MergeContent_SubscriberId,  tb.RowId as MergeContent_RowId,  tb.RowVer as MergeContent_RowVer,  t.ChangeDate as MergeContent_ChangeDate, -1 as MergeContent_Action,   null as MergeContent_SyncId   from `person` tb left join `person` vw on tb.RowId=vw.RowId left join `MergeContent_person` t on vw.RowId=t.RowId and t.SubscriberId=1 where (t.RowVer<>tb.RowVer or t.RowId is null)   union all select  t.*,2 as MergeContent_TableId,   1 as MergeContent_SubscriberId,  m.RowId as MergeContent_RowId,  m.RowVer as MergeContent_RowVer,  m.ChangeDate as MergeContent_ChangeDate,   3 as MergeContent_Action,   null as MergeContent_SyncId   from `MergeContent_person` m left join `person` vw on m.RowId=vw.RowId and m.SubscriberId=1   left join `person` t on vw.RowId=t.RowId  where vw.RowId is null  and m.SubscriberId=1  ) as mergeVw
2020-10-19 14:05:41,392 TRACE [ {
  "TableName" : "person",
  "Records" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><records><r a=\"1\"><c>1</c><c>q</c><c>y</c><c>2543d43a-11b3-11eb-819d-309c23bf0c2c</c></r><r a=\"1\"><c>2</c><c>w</c><c>i</c><c>2543dec8-11b3-11eb-819d-309c23bf0c2c</c></r><r a=\"1\"><c>3</c><c>e</c><c>p</c><c>2543dfb2-11b3-11eb-819d-309c23bf0c2c</c></r><r a=\"1\"><c>4</c><c>giao</c><c>1</c><c>2543e093-11b3-11eb-819d-309c23bf0c2c</c></r></records>",
  "QueryInsert" : "INSERT INTO person ([PersonID],[LastName],[FirstName],[RowId]) VALUES (?,?,?,?);",
  "QueryUpdate" : "UPDATE person set [LastName]=?,[FirstName]=?,[RowId]=? where PersonID=?;",
  "QueryDelete" : "DELETE FROM person where RowId=",
  "TriggerInsert" : "",
  "TriggerUpdate" : " CREATE TRIGGER IF NOT EXISTS \"trMergeUpdate_person\"     AFTER UPDATE OF [LastName],[FirstName]    ON \"person\"  BEGIN  \tUPDATE \"person\" SET MergeUpdate = 1 WHERE RowId = old.RowId and RowId<>'';  END; ",
  "TriggerDelete" : " CREATE TRIGGER IF NOT EXISTS \"trMergeDelete_person\"     AFTER DELETE     ON \"person\"   BEGIN \t  \tINSERT INTO MergeDelete values (2,  old.RowId);  END; ",
  "TriggerInsertDrop" : "DROP TRIGGER IF EXISTS \"trMergeInsert_person\"",
  "TriggerUpdateDrop" : "DROP TRIGGER IF EXISTS \"trMergeUpdate_person\"",
  "TriggerDeleteDrop" : "DROP TRIGGER IF EXISTS \"trMergeDelete_person\"",
  "SyncId" : 21,
  "SQLiteSyncVersion" : "3.2.16"
} ]

Please help!

supertom495 commented 3 years ago

So mainly is : 2020-10-19 14:05:40,971 ERROR CommitChangesToDb() ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog.

Can u please give more detail error log or how should I fix this error?

supertom495 commented 3 years ago

The reason is I JsonStringfy the content I send, so the server received the contents like '\ in the beginning, so the server does not understand the content I send. Just double check the content you send if you have the same problem