Answered by:
Hints needed for implementing file sync over WCF

Question
-
Hi,
I'm trying to implement file sync over WCF and I need some guidance.
My idea was to try to modify the RCA example in Sync101 to do file sync using two FileSyncProviders. I want to instantiate one provider locally and the other inside the service and then connect them through WCF.
I think I got the philosophy right - using IFileDataRetriever etc. I also kind of managed to get the solution working but I have one problem... It seems to be related with the SyncSessionContext: the context is passed as an argument in the BeginSession method, but since it's not serializable (it's not even fully managed code, from what I've seen) I figured I had to create my own separate session context inside the remote provider. When I do that, the call to ProcessChangeBatch on the remote FileSyncProvider throws a ComException with the (non-)message "Operation is not valid due to the current state of the object."
For testing purposes, I then skipped WCF and ran both providers in the client but behaved as if they were separated - this allowed me some experimentation with non-serializable objects that I couldn't do over WCF. If I take the advantage of this and use the same SyncSessionContext for both providers, it works. So, separate contexts = no go, same context (impossible over WCF) = working.
Can anyone give me a clue as to what I'm missing? Are the sync providers somehow communicating through the session context? (Hardly likely, from what I've seen - otherwise the simple custom file sync provider sample wouldn't work). Does the provider check the state of the session and throw this exception if it missed a sync step? I also tried wiring the SyncCallbacks object in various ways so I can react to its ProgressChanged event and update progress status on the other session, but it didn't solve the problem (or I missed the right combination). Did I also need to route other events from one to the other? If anyone is willing to take a look at my code, I'd be glad to post it somewhere for download (it's a spin-off of the Sync101 RCA sample so it shouldn't be hard do decipher).
As an aside, I did look at the custom file provider sample for this purpose. The first problem with it is that it uses the simple provider and I don't know how to connect it with FileSyncProvider via WCF (that is, connect KnowledgeSyncProvider's RCA methods to SimpleSyncProvider methods) - unless I run both of them locally and use WCF inside the custom provider, and I didn't know what the consequences of that would be (having to send the metadata store over WCF? etc) so I opted for FileSyncProvider on both ends. If I was wrong (or there's a third option), please let me know.
Thanks in advance!
Saturday, April 17, 2010 10:23 PM
Answers
-
Hi Boris,
Yes, you've stumbled upon an unfortunate limitation of the FSP. Alas, until we fix this issue, the workaround isn't the most elegant solution.
Basically, what you can do is use a dual syncsession approach. One on the client one on the server. You essentially have two custom providers (KnowledgeSyncProviders) and two FSPs:
FSP -> ClientProxyProvider -> |Network| -> RemoteProxyProvider -> FSP
Sync Session ^ Sync Session ^
The two custom providers essentially serve to pass along the changebatches created by the FSPs. There is some trickyness, however. The ClientProxyProvider will need to implement a data retriever that can work over the network (an example is one that caches all the change data within the object sent over the wire).
-Jesse
- Proposed as answer by Jandeep Thursday, April 29, 2010 11:46 PM
- Marked as answer by Sid Singh [MSFT]Microsoft employee Thursday, May 27, 2010 12:29 AM
- Edited by Jesse L - MSFT Monday, July 30, 2012 3:59 PM
Thursday, April 29, 2010 10:50 PM
All replies
-
Hi Boris,
Yes, you've stumbled upon an unfortunate limitation of the FSP. Alas, until we fix this issue, the workaround isn't the most elegant solution.
Basically, what you can do is use a dual syncsession approach. One on the client one on the server. You essentially have two custom providers (KnowledgeSyncProviders) and two FSPs:
FSP -> ClientProxyProvider -> |Network| -> RemoteProxyProvider -> FSP
Sync Session ^ Sync Session ^
The two custom providers essentially serve to pass along the changebatches created by the FSPs. There is some trickyness, however. The ClientProxyProvider will need to implement a data retriever that can work over the network (an example is one that caches all the change data within the object sent over the wire).
-Jesse
- Proposed as answer by Jandeep Thursday, April 29, 2010 11:46 PM
- Marked as answer by Sid Singh [MSFT]Microsoft employee Thursday, May 27, 2010 12:29 AM
- Edited by Jesse L - MSFT Monday, July 30, 2012 3:59 PM
Thursday, April 29, 2010 10:50 PM -
Hi Jesse,
Could you please help? I need the code mentioned above in your reply. Would you like me to send you an email?
-Paul Pahwa
Friday, June 25, 2010 2:44 AM -
Jesse,
Thanks for your information. I sent you an email requesting the code examples as well as some other information. I look forward to hearing from you and I hope you are able to reply soon.
John
Tuesday, June 29, 2010 6:00 PM -
Hi Jesse
I am fighting with this functionality to no avail... could you post the code you referenced?
Thanks
Tuesday, August 24, 2010 5:53 PM -
Hi Jesse,
can i have the sample code ?
thanks
best regards
holgi
Friday, January 7, 2011 10:15 AM -
-
Hi Jesse,
Would you be able to email me the sample code that you mentioned in your post?
Many Thanks,
-Gary
Monday, February 14, 2011 3:45 PM -
Hi Jesse,
Could you please send me the sample code?
Thanks in advance...
Wednesday, February 16, 2011 10:26 AM -
Is it possible to implement file sync over WCF.I went through the samples,but i could get any clue.
File transfer in local system is working fine. now i have created the wcf service for authentication. I saw few threads suggested to create KSP(KnowledgeSyncProvider ) in which i dont have any clue to start.
can anyone share some code logic ?
Thursday, February 17, 2011 2:03 PM -
Hello,
I mentioned above that I have some code. However, after I gave it out to a few people they found that it was still quite a bit of work to get FSP to work over WCF. I can't say I recommend this approach at this time. The FSP was never really designed/tested for this and there end up being a bunch of issues to work through. Perhaps at some point we will release a full sample solution, but it is not a priority for the sync framework team right now.
If you still really want the pieces of code I have to start you off, you can email me at the address above. I can't provide much support after that.
-Jesse
Thursday, February 17, 2011 7:55 PM -
Jesse it has been a year since the last post. Has there been any change on the status of FSP over WCF? Is there a better sample to use?
-Dale
Tuesday, April 3, 2012 3:04 PM -
Hi, I know this post is really old and probably dead, but has someone finally found a workaround or a way to fix the issue?
I just hit the same exact wall and don't know what to do.
have you solved the problem?
Sunday, December 1, 2013 5:33 PM