2 / 10
Jul 2022

I get the following error when syncing my app;

User mismatch for client file identifier (IDENT)

I know why the error is being raised, my question is why isn’t the error returned to my code?

The following shows the log entries raised by the SDK;

2022-07-15 05:17:05.055 Info: Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, client reset = false 2022-07-15 05:17:05.126 Info: Connected to endpoint '13.54.209.90:443' (from '127.0.0.1:59626') 2022-07-15 05:17:05.148 Info: Verifying server SSL certificate using 155 root certificates 2022-07-15 05:17:05.971 Info: Connection[1]: Session[1]: Received: ERROR "User mismatch for client file identifier (IDENT)" (error_code=223, try_again=true, recovery_disabled=false) 2022-07-15 05:17:05.984 Info: Connection[1]: Disconnected 2022-07-15 05:17:08.004 Info: Connected to endpoint '13.54.209.90:443' (from '127.0.0.1:59627') 2022-07-15 05:17:08.025 Info: Verifying server SSL certificate using 155 root certificates 2022-07-15 05:17:08.336 Info: Connection[1]: Session[1]: Received: ERROR "User mismatch for client file identifier (IDENT)" (error_code=223, try_again=true, recovery_disabled=false) 2022-07-15 05:17:08.336 Info: Connection[1]: Disconnected 2022-07-15 05:17:12.357 Info: Connected to endpoint '13.54.209.90:443' (from '127.0.0.1:59630') 2022-07-15 05:17:12.377 Info: Verifying server SSL certificate using 155 root certificates 2022-07-15 05:17:12.566 Info: Connection[1]: Session[1]: Received: ERROR "User mismatch for client file identifier (IDENT)" (error_code=223, try_again=true, recovery_disabled=false) 2022-07-15 05:17:12.567 Info: Connection[1]: Disconnected 2022-07-15 05:17:20.588 Info: Connected to endpoint '13.54.209.90:443' (from '127.0.0.1:59631') 2022-07-15 05:17:20.609 Info: Verifying server SSL certificate using 155 root certificates 2022-07-15 05:17:20.799 Info: Connection[1]: Session[1]: Received: ERROR "User mismatch for client file identifier (IDENT)" (error_code=223, try_again=true, recovery_disabled=false) 2022-07-15 05:17:20.800 Info: Connection[1]: Disconnected

My code uses a cancellation token to cancel the procedure if the realm isn’t opened within a suitable timeframe but it would be far more efficient if the SDK returned an error for my code to handle.

Often times, including the code you’re using can help clarify the question and can give us a bit more insight as to when any why the error is ocurring. Can you include the code you’re using?

Following is the code used;

public static async Task<(bool Synchronised, Realm Realm)> GetSyncedRealm(SyncConfiguration config, int timeout = 2) { Realm realm = null; var cts = new CancellationTokenSource(); cts.CancelAfter(TimeSpan.FromSeconds(timeout)); try { realm = await Realm.GetInstanceAsync(config, cts.Token); return (true, realm); } catch (OperationCanceledException) { return (false, realm); } catch (Exception ex) { Trace.WriteLine(ex.GetFirstMessage()); throw; } }

The error User mismatch for client file identifier (IDENT) is shown multiple times in the log until the cancellation token expires and control is returned to the code. This occurs for other errors raised by the SDK but are never thrown to the calling code to be handled. If the code did get these errors we could take steps to correct the problem.

Hi Andrea,

Thanks for the tip. I tried adding the OnSessionError handler as you suggested;

private async Task SetupRealmEnvironment() { _adminUser = await GetRealmUser(_realmAppId, _realmSettings.AdminUser, _realmSettings.PIN); if (_adminUser == null) throw new Exception($"Failed to locate a Realm user for \"{_realmSettings.AdminUser}\"."); PartitionSyncConfiguration syncConfig = ConnectionService.GetSyncConfig(Enums.AppConfiguration.CrmRealmWebApi, RealmConstants.PUBLIC_PARTITION, _adminUser); syncConfig.ClientResetHandler = new ManualRecoveryHandler(HandleResetError); //syncConfig.OnSessionError = new SyncConfigurationBase.SessionErrorCallback(HandleSessionError); syncConfig.OnSessionError += HandleSessionError; (bool IsSynced, Realm realm) result; result = await ConnectionService.GetSyncedRealm(syncConfig, 20); if (result.realm == null) throw new Exception("Failed to open a synchronised or local realm for the Admin user."); if (!result.IsSynced) { await result.realm.SyncSession.WaitForDownloadAsync(); result.IsSynced = true; } _realm = result.realm; _driverSvc = new SxRealm.Services.DriverService(_realm); } private static void HandleSessionError(Session session, SessionException error) { Console.Write($"{error}"); }

But the code never hit the Console.Write($"{error}"); line even though the following error was displayed in the session logs;

2022-07-19 01:36:06.790 Info: Connection[1]: Session[1]: Received: ERROR "Invalid schema change (UPLOAD): failed to add app schema for ns='mongodb-atlas.DriverApp.Driver' for new top-level schema "Driver": sync-incompatible app schema for the same collection already exists. This app schema is incompatible with error: "property \"AppVersion\" has invalid type: type [string,null] is not supported, property \"DepotId\" has invalid type: type [uuid,null] is not supported, property \"Email\" has invalid type: type [string,null] is not supported, property \"LastPingDtTm\" has invalid type: type [date,null] is not supported, property \"LastProcessedDtTm\" has invalid type: type [date,null] is not supported, property \"Mobile\" has invalid type: type [string,null] is not supported". To continue, delete the app schema in Atlas App Services, or update it to match the app schema defined on the device" (error_code=225, try_again=false, recovery_disabled=false)

As you can see from the code above I tried configuring the handler using;

syncConfig.OnSessionError = new SyncConfigurationBase.SessionErrorCallback(HandleSessionError)

and

syncConfig.OnSessionError += HandleSessionError

Were these hooked up correctly?

The code that you showed should not compile as
ManualRecoveryHandler takes the delegate ClientResetCallback which expects a ClientResetException as parameter. But you pass a delegate with 2 parameters, a Session and a SessionException.
Are you sure you’re running the code that you are showing?

As a side note, OnSessionError is not an event, so there’s no need to use the subscribe syntax (+=). OnSessionError is a property so just set (=) your callback.


About client reset, we strongly encourage not to use the manual client strategy. Instead, users are encouraged to use the discard local strategy as that is generally much simpler to use (but be sure you understand that it discards unsynced changes in the event of a client reset).


Your code should look like

PartitionSyncConfiguration syncConfig = ConnectionService.GetSyncConfig(Enums.AppConfiguration.CrmRealmWebApi, RealmConstants.PUBLIC_PARTITION, _adminUser); syncConfig.OnSessionError = (sender, e) => { Console.Write($"Session error code {e.ErrorCode}: {e.Message}"); // handle the various session errors here switch(e.ErrorCode) { case ErrorCode.UserMismatch: // this should be the one you're experiencing break; case ErrorCode.*SomeCode*: break; case ErrorCode.*SomeCode*: break; // etc default: break; } }; syncConfig.ClientResetHandler = new DiscardLocalResetHandler { // All of the following callbacks are optional, I put them here just to make you aware. // You can skip them for now. OnBeforeReset = (beforeFrozen) => { /* your code */ }, OnAfterReset = (beforeFrozen, after) => { /* your code */ }, ManualResetFallback = (clientResetException) => { /* your code */ }, };


When I said:

you need to set a callback in SyncConfigurationBase.OnSessionError

I simply meant any subclass of SyncConfigurationBase, not the base class itself.

I hope this helps.

Hi Andrea,

Thanks for your assistance however I’m still having problems with the OnSessionError and ClientResetHandler so I’ve raised a support ticket.

What type of problems? Is your OnSessionError callback never reaching? Or what is the problem?

And where did you raise a support ticket? We usually monitor a bunch of resources but none of those show your ticket.

Hi,

Apparently I don’t have access to that portal, that’s why I could not see the ticket. I hope they can help you figure out what the problem is.

Andrea