I'm unable to get the SwiftUI template app to maintain a connection over flexible sync

The SwiftUI template todo app is unable to maintain a connection with MongoDB. The app itself works just fine, but it is unable to sync. The steps I’m taking are:

  1. Create a new app and download zip file that contains the template SwiftUI app from Atlas App Services
  2. Ensure appId and appUrl are correct in atlasConfig.plist
  3. Build and launch app on iPhone 14 Pro simulator
  4. Create a user via app and log in to the app
  5. Create todo items

I can see the created user in App Services, but no todos are ever synced. Opening the app on a different simulator confirms that there is no syncing happening. The following is output when the app launches and attempts to connect to flexible sync (I’ve removed some identifying info from these logs):

Sync: Realm sync client ([realm-core-13.10.1])
Sync: Connection[1]: Session[1]: Binding '[obfuscatedpath]/flx_sync_default.realm' to ''
Sync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, client reset = false
Sync: Connected to endpoint 'x.xx.xxx.xx:xxx' (from 'xxx.xxx.x.xx:xxxxx')
Sync: Connection[1]: Closing the websocket with status='SystemError: invalid certificate chain', was_clean='false'
Sync: Connection[1]: Connection closed due to error

If you’re using Realm, I would suggest going through the SwiftUI Getting Started guide and the following the instructions in the Add Sync section as those have been thoroughly vetted.

I am a bit unsure if that’s a correct step - where are you seeing those instructions?

Thanks Jay, I’ll give it the Getting Started guide a shot.

Those instructions are in the README of the template app, see here:

The template app actually downloads with the correct values set in the plist file, so this step was just confirming the values are correct; I didn’t actually have to change anything.

Ah - yes, I see. A little different approach than what’s outlined in the guide but the result is the same.

/// When you create your own Atlas Device Sync app, use your preferred method
/// to store and access app configuration details.

Thanks for the link!


This message is certainly vague:

Sync: Connected to endpoint 'x.xx.xxx.xx:xxx' (from 'xxx.xxx.x.xx:xxxxx')

It’s almost like it doesn’t recognize the endpoint. Did you go through and create the App etc in the Realm Console - maybe you did in step 1?

See Create a Template App if not

Then, log into the console, navigate to your app, scroll to to Logs and then View All Log Activity and see if there are any message or errors indicated there.

Jay