none
Why does WebSharingAppDemo-CEProviderEndToEnd sample still need a client db connection after scope creation to perform sync RRS feed

  • Question

  • I'm researching a way to build an n-tierd sync solution. From the WebSharingAppDemo-CEProviderEndToEnd sample it seems almost feasable however for some reason, the app will only sync if the client has a live SQL db connection. Can some one explain what I'm missing and how to sync without exposing SQL to the internet?
    Tuesday, March 2, 2010 7:00 PM

Answers

  • Hi,

    I looked at WebSharingAppDemo-CEProviderEndToEnd sample, it doesn't have the line in ServerSynchronizationHelper.cs as you mentioned.

        provider.Connection.Open(); 

    Did you add this line on top of the original sample code? It seems not  needed to me.

    For the Batch file not available issue, you may want to remove IsOneWay=true setting from IRelationalSyncContract.UploadBatchFile. When the Bathc file size is big, AppleChanged will be called even before fully completing the previous UploadBatchfile.

    [

    OperationContract(IsOneWay = true)]

     

    void UploadBatchFile(string batchFileid, byte[] batchFile, string remotePeerI



    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Thursday, March 4, 2010 6:03 AM
    Moderator

All replies

  • hi don,

    I may have gotten your question wrong, but AFAIK, the sample you just mentioned does not actually expose your SQL to the internet. Your client is actually talking to a WCF endpoint in the scenario. Your WCF endpoint is exposed, but your SQL may be well entrenched somewhere inside your network.

    The client still needs a connection to perform sync because scope creation simply tells SyncFx to create the objects for change tracking and syncronization and to save the configuration of what needs to be synch in a given scope.

    In order to perform the sync, the client needs to connect to its database to enumerate changes that needs to be uploaded and to apply changes that it receives.

    cheers,

    junet
    Wednesday, March 3, 2010 3:06 AM
    Moderator
  • I agree that the purpose of the sample is to encapsulate SQL behind a WCF endpoint. The problem I'm experiencing is that when I provide a Relational sync provider that has an open SQL connection from the client, then it works fine but when I provide a Relational sync provider that has a closed but configured connection string, as in the example, I get an error from the WCF stating that the server did not receive the batch file. So what am I doing wrong?

          SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
          builder.DataSource = hostName;
          builder.IntegratedSecurity = true;
          builder.InitialCatalog = "mydbname";
          builder.ConnectTimeout = 1;
          provider.Connection = new SqlConnection(builder.ToString());

          // provider.Connection.Open();  ** un-commenting this causes the code to work

          //create anew scope description and add the appropriate tables to this scope
          DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(SyncUtils.ScopeName);

          //class to be used to provision the scope defined above
          SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning();
    ....


    The error I get occurs in this part of the WCF code:

        public SyncSessionStatistics ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeData)
        {
          Log("ProcessChangeBatch: {0}", this.peerProvider.Connection.ConnectionString);

          DbSyncContext dataRetriever = changeData as DbSyncContext;

          if (dataRetriever != null && dataRetriever.IsDataBatched)
          {
            string remotePeerId = dataRetriever.MadeWithKnowledge.ReplicaId.ToString();
            //Data is batched. The client should have uploaded this file to us prior to calling ApplyChanges.
            //So look for it.
            //The Id would be the DbSyncContext.BatchFileName which is just the batch file name without the complete path
            string localBatchFileName = null;
            if (!this.batchIdToFileMapper.TryGetValue(dataRetriever.BatchFileName, out localBatchFileName))
            {
              //Service has not received this file. Throw exception
              throw new FaultException<WebSyncFaultException>(new WebSyncFaultException("No batch file uploaded for id " + dataRetriever.BatchFileName, null));
            }
            dataRetriever.BatchFileName = localBatchFileName;
          }



    Any ideas?

    Wednesday, March 3, 2010 2:09 PM
  • Hi,

    I looked at WebSharingAppDemo-CEProviderEndToEnd sample, it doesn't have the line in ServerSynchronizationHelper.cs as you mentioned.

        provider.Connection.Open(); 

    Did you add this line on top of the original sample code? It seems not  needed to me.

    For the Batch file not available issue, you may want to remove IsOneWay=true setting from IRelationalSyncContract.UploadBatchFile. When the Bathc file size is big, AppleChanged will be called even before fully completing the previous UploadBatchfile.

    [

    OperationContract(IsOneWay = true)]

     

    void UploadBatchFile(string batchFileid, byte[] batchFile, string remotePeerI



    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Thursday, March 4, 2010 6:03 AM
    Moderator