I fired up a new ROS on a Google Cloud Compute ubuntu vm and am trying to write objects via a Xamarin.Android project:
public class TestObject : RealmObject
{
public string TestString { get; set; }
public int TestInt { get; set; }
}
//new non-existent realm, I also tried a public realm -> realm://###.###.###.###/newrealm
var realmUrl = "realm://###.###.###.###/~/newrealm";
//preconfigured admin credentials
var creds = Credentials.UsernamePassword("[email protected]", "password", false);
var user = await User.LoginAsync(creds, new Uri("http://###.###.###.###:9080"));
var config = new SyncConfiguration(user, new Uri(realmUrl));
var realm = Realm.GetInstance(config);
//this event never fires
Session.Error += (sender, errorArgs) => { var ex = errorArgs.Exception; };
//left this in just to be sure there were no permissions issues
await user.ApplyPermissionsAsync(PermissionCondition.Default, realmUrl, AccessLevel.Write);
//this will contain objects on subsequent runs
var existing = realm.All<TestObject>().ToList();
//also tried realm.Write(() => { });
using (var trans = realm.BeginWrite())
{
var test = new TestObject();
test.TestString = "test";
test.TestInt = 99;
realm.Add(test);
trans.Commit();
};
The result is that the new realm is created successfully on the remote ROS, but it remains empty according to the dashboard and the Realm Browser even after multiple runs of this code. You'll notice in my comment that the local realm does contain the written objects, just not the remote. The server logs show a lot of messages when this code is executed, but there are no warnings or errors. What have I missed?
Thanks to Nikola for figuring out I was missing the port number on the realm url. After adding it, everything seems to be working correctly.
var realmUrl = "realm://###.###.###.###:9080/~/newrealm";
Seems odd that no errors of any kind were thrown, objects were just silently not written to the remote realm.