This Realm has no schemas defined


#1

I’m writing a Xamarin app against a Cloud Realm. I can log on, create an object, write it to the realm, and get some objects back out of the realm so I know that it contains something. However, when I look at the realm in Realm Studio I just get a blank window with the message “This Realm has no schemas defined”.
Shouldn’t Realm Studio just be able to show me what objects are in the realm, or do I have to do something else (define a schema?) to get it to do so?
And where can I find any docs on Realm Studio?
Thanks, Stu.


#2

Hmmm… actually I think the problem might be with the sync - the cloud realm probably is empty and the items I am seeing are just on the device. This is confirmed by deleting the cloud realm and the device still giving the same results. Will have to investigate further…


#3

Can you share how you’re connecting to cloud? Notably, make sure you’re using https:// and realms:// url schemes as the cloud instances only support SSL.


#4

Hi @nirinchev

I call the following code in the constructor of my page and it runs fine, adds a pattern object to the realm, and lists the realm’s contents in a listview so I can see that it has done this.

private async void CreateOnlineRealmAsync()
        {
            var credentials = Credentials.UsernamePassword("devAdmin", "devAdmin", false);
            var authURL = new Uri("https://rt1.us1a.cloud.realm.io");
            var user = await User.LoginAsync(credentials, authURL);

            var serverURL = new Uri("realms://rt1.us1a.cloud.realm.io:9080/OnlinePatterns");
            var configuration = new SyncConfiguration(user, serverURL);
            configuration.EnableSSLValidation = false;

            //Realm.DeleteRealm(configuration);

            Realm onlinePatterns = Realm.GetInstance(configuration);

            try
            {
                onlinePatterns.Write(() => {
                    OnlinePattern pattern = new OnlinePattern {
                        Company = "Simplicity",
                        Name = DateTime.Now.Second.ToString(),
                        GarmentTypes = "skirt,blouse,dress"
                    };
                    onlinePatterns.Add(pattern);
                });
                Text1 = "Done";
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                Debug.WriteLine($"/n/n#### ---- ERROR ---- #### /n/n{ex.Message}/n/n");
            }

            var p = onlinePatterns.All<OnlinePattern>();
            PatternsList = p;
        }

When I check online the realm has been created, but is empty.

If I wait several minutes then the following appears in the VISUAL studio output window

Thread started: <Thread Pool> #10
ERROR: Connection[1]: Failed to connect to endpoint '35.161.113.247:9080': Connection refused
Thread finished: <Thread Pool> #10
Thread started: <Thread Pool> #11
ERROR: Connection[1]: Failed to connect to endpoint '52.27.168.188:9080': Connection refused
Thread finished: <Thread Pool> #11
Thread started: <Thread Pool> #12
ERROR: Connection[1]: Failed to connect to endpoint '35.164.0.194:9080': Connection refused
ERROR: Connection[1]: Failed to connect to 'rt1.us1a.cloud.realm.io:9080': All endpoints failed
Thread finished: <Thread Pool> #12

I get the same results if I have the line configuration.EnableSSLValidation = false; enabled or commented out.
The user is an administrator, and I have tried using both "realms://rt1.us1a.cloud.realm.io:9080/OnlinePatterns" and "realms://rt1.us1a.cloud.realm.io:9080/~/OnlinePatterns" as the urls (both realms are created, both remain empty).


#5

You should remove the 9080 port from the serverURL. The cloud instances are setup to redirect the ports to the default one (443 for SSL connections), so you can simply use realms://rt1.us1a.cloud.realm.io/OnlinePatterns.


#6

Thanks - that fixed it :slight_smile:


#7

Hi,

Im having the same issue.
Im using both https:// and relams:// without the port and still the realm at the cloud is created empty.
I am using administrator user to create and populate it.
I see no errors in the realm cloud log.
I have the data locally but in the clouds it says “This Realm has no schemas defined”.

Any idea?

Btw - it works well against AWS


#8

Can you share a simple repro project that I can try to run against my instance?


#9

just set the email,password and cloud server name (without https://)

import React from 'react';
import {Text} from 'react-native';

class Country{}

Country.schema = {
    name:'Country',
    primaryKey: 'id',
    properties:{
        id: 'int',
        name : {type: 'string'},
        code : {type: 'string'},
    }
}


const email     = 'admin'; // this is the user doing the copy
const password  = '1234';
const realm_server = 'XXXXXXXX';

export default class SignInForm extends React.Component{


  constructor(props) {
     super(props);

        Realm.Sync.User.login("https://"+realm_server, email, password)
          .then(user => {

            let schemasArr = [Country];


            const config = {
              sync: { user: user,
                      url: 'realms://'+realm_server+'/publicRealm'
                    },
               schema:schemasArr
            };

            var realm =  new Realm(config);
            realm.write(() => {

              realm.create('Country', {id: 1 ,name:'Italy' ,code:'IT'});

            });

          })
          .catch(error => { alert(error);});
      }

      render(){
        return(
            <Text>OK</Text>
        )
      }


  }


#10

I’m not familiar with React, but my guess is that the realm variable gets garbage collected before Realm can finish uploading the changes (including the schema) to the cloud.


#11

Thank you, but since this is working fine against AWS I dont think this is the problem.
Any other thoughts?


#12

I think it’d be best to file an issue against the realm-js repo so the team can properly investigate. There’s nothing obviously wrong, but as I said, I’m mostly a .NET guy, so I may be missing some intricacies.


#13

UPDATE -

managed to solve this by adding validate_ssl:false to the configuration object.

Thank you


#14

This probably means you’re not using the latest version of the js SDK.


#15

Had exactly the same issue as OP this morning on the latest version of Realm for xamarin and using Realm Cloud. Only thing that created my schemas was adding the line
.EnableSSLValidation = false;
to my code.