Sync not working

I’m following the getting Tasks app tutorials. Each time I quit the tasks app and restart it. The list is populated with tasks, but syncing does not work. Sync only works the first time the app runs. In order to get it working again, I have to delete the app from my device and relaunch it. As long as the app is running for the first time sync works. Any ideas?

The following is printed to the console:

Sync: Connection[2]: Websocket: Expected HTTP response 101 Switching Protocols, but received:

HTTP/1.1 404 Not Found

Cache-Control: no-cache, no-store, must-revalidate

Content-Length: 4

Content-Type: text/plain; charset=utf-8

Date: Mon, 15 Jun 2020 02:44:13 GMT

Vary: Origin

X-Content-Type-Options: nosniff

X-Frame-Options: DENY

404

1 Like

We need to know what platform you’re using, how your authentication is set up (and the code) and then how you’re connecting to Realm (code). So we really need to see some code.

After some trial and error I discovered this to be specific to my iPhone. Since it was not occurring in the iOS simulator or on another iOS device I tired.

I’m using iOS 13.5.1 and Xcode 11.5 (11E608c)

The code was direct from the tutorial.

I was able to rectify the problem by deleting the tutorial task app from the iPhone, restarting the iPhone then reinstalling the task app. It appears to be working normally now.

Hello @Rob_Cummings,

What are you passing for “Partition”?

Can you please share iOS snippet code if possible?

Thanks in advance.

Sorry guys, I got it working as described in previous post. I’ve since deleted to tutorial project.

Hi, I am using the Realm SDK for Unity and getting the same Error:
‘’’
Error: Websocket: Expected HTTP response 101 Switching Protocols, but received:
HTTP/1.1 404 Not Found
‘’’
This is how I am trying to connect to the application:
‘’’
async void OnEnable(){

    var app = App.Create("My-Realm-App-Id");

    var user = app.CurrentUser;

    if(user == null){

    user = await app.LogInAsync(Credentials.Anonymous());

    var syncConfig = new FlexibleSyncConfiguration(app.CurrentUser);

    _realm0 = await Realm.GetInstanceAsync(syncConfig);

    }else{

    var syncConfig = new FlexibleSyncConfiguration(app.CurrentUser);

    _realm0 = Realm.GetInstance(syncConfig);

   

    }

    _realm0.Subscriptions.Update(() =>

    {

        _realm0.Subscriptions.Add(_realm0.All<Usuarios_data>(),new SubscriptionOptions {Name = "RegistrarSubscription"});

    });

‘’’
I have already checked that I have set the permissions and enabled Anonymous Authentication, so I do not know what can be failing.
Thanks :slight_smile:

Similar problem here.

Sync: Websocket: Expected HTTP response 101 Switching Protocols, but received:
HTTP/1.1 401 Unauthorized
cache-control: no-cache, no-store, must-revalidate
connection: close
content-length: 212
content-type: application/json
date: Fri, 27 Jan 2023 22:59:45 GMT
server: mdbws
strict-transport-security: max-age=31536000; includeSubdomains;
vary: Origin
x-appservices-request-id: 63d45761629bbbb2087a6128
x-envoy-max-retries: 0
x-frame-options: DENY
2023-01-27 17:59:45.015076-0500 Foody23[4788:57544] Sync: Connection[1]: Connection closed due to error

I’m using the following code in RealmSwift

let ra = RealmSwift.App(id: "foody23realm-jfsbk")
let realmUserKey = *** not showing API key in public post *** // DevUser23 API key
let credentials = Credentials.userAPIKey(realmUserKey)

 do {
        let thisUser = try await ra.login(credentials: credentials)
        var loginConfiguration = thisUser.configuration(partitionValue: uuidFamily, clientResetMode: .discardUnsyncedChanges()) /// uuidFamily is a UUID value I would prefer not to publish in a public post
        loginConfiguration.objectTypes = [Categories.self,
                                          Commodities.self,
                                          Units.self,
                                          Stores.self,
                                          Accounts.self,
                                          ShoppingItems.self
                                          Ledgers.self,
                                          Journals.self,
                                          Vehicles.self,
                                          Packages.self]
    let realm = try await Realm(configuration: loginConfiguration, downloadBeforeOpen: .always)
} catch {
    fatalError("WARNING: Can't run without database access; \(devDate.timeIntervalSinceNow)")
}

Any suggestions?

I took a look at your backend app and you have a lot of successful writes occurring - are you still experiencing this issue?