Unclear errors when trying to set-up Device Sync for the first time

I haven’t used Realm since before it was acquired by MongoDB, so I might be missing some concepts to make things work.

When trying to connect using the Swift SDK on a macOS app using Flexible Sync, I’m getting the following errors looped in my console log:

Info: Connection[1]: Connecting to 'wss://ws.us-east-1.aws.realm.mongodb.com:443/api/client/v2.0/app/memory-fuaet/realm-sync'
Info: Connected to endpoint '' (from '')
Info: Connection[1]: Closing the websocket with error code=WebSocket: OK, message='', was_clean=true
Error: Reading failed: End of input
Info: Connection[1]: Closing the websocket with error code=WebSocket: Read Error, message='End of input', was_clean=false
Info: Connection[1]: Connection closed due to transient error: ConnectionClosed: End of input

When looking in the Atlas console I’m seeing the following error:

error handling “bind” message: error getting sync status from metadata store: error getting initial sync status: mongo: no documents in result

My code is straightforward, and even though login succeeds, seems that actually opening sync is failing:

let app = RealmApp(
    id: realmConfig.appId,
    configuration: AppConfiguration(baseURL: realmConfig.baseUrl, transport: nil)

let user = try await app.login(
    credentials: .emailPassword(
        email: ...,
        password: ...

// login is successful and im getting a valid user here

var config = user.flexibleSyncConfiguration(
    clientResetMode: .recoverOrDiscardUnsyncedChanges()

config.objectTypes = [Tag.self]

let realm = try await Realm(
    configuration: config,
    downloadBeforeOpen: .once

Tag looks like this:

public class Tag: Object {
    @Persisted(primaryKey: true) public var _id: ObjectId
    @Persisted public var name = ""
    @Persisted public var ownerId: String
    public convenience init(name: String, ownerId: String) {
        self.name = name
        self.ownerId = ownerId

Things I’ve tried:

  1. In Data Services → Database, tried to create my database with the relevant model with a dummy piece of data
  2. In App Services → Schema, I’ve tried defining the schema by hand to match the Database model
  3. I looked in Queryable Fields and things seem right…

Any pointers / guidelines would be immensely helpful.


1 Like

Hi, if you go to the deployment section of your application you will see that some errors occurred while setting up the application / device sync.

We will look into it, but in the meantime, can you:

  1. Terminate Sync
  2. Deploy Draft
  3. Enable Sync
  4. Deploy Draft

That should get things working again.


Hey Tyler,
Thanks for the prompt response.

Deploying the draft seems to fail as well, I tried discarding all changes and starting over but that didn’t help either.

1 Like

Hmm, that is indeed odd. I will tag someone from that team on this. Can you try disabling drafts (on the deployment page).

Then you should just need to terminate sync and re-enable and things should get working.

Thanks for the suggestions,
I tried that but I’m getting the same failures /:

Anything else I could be missing?

1 Like

My apologies for losing track of this. I am querying some people about this because I have not seen this issue before. Can you try creating a new application? I suspect something funny happened where the app got into a weird state. I am looking into why that is, but I suspect you wont run into this again with a new application.

If you do, it would be helpful to know exactly how you are creating the application, as we have not seen this in the past.