Realm-java: E/REALM_SYNC: Connection[1]: Writing failed: End of input

Created on 31 Oct 2017  路  31Comments  路  Source: realm/realm-java

I need help on why i get there console log "E/REALM_SYNC: Connection[1]: Writing failed: End of input" when I call this.

new Thread(new Runnable() {
@Override
public void run() {
try {
// opens realm
realm = Realm.getDefaultInstance();
// get all userContacts
userContacts = realm.where(UserContact.class).findAll();
} finally {
if (realm != null) {
realm.close();
}
}
}
}).start();

T-Help

Most helpful comment

Oh, I was able to display it now 馃憤 Thanks for the help :)

All 31 comments

what is your Realm version?

classpath "io.realm:realm-gradle-plugin:4.1.0"

Oh, I cant replicate it now after correcting my REALM_URL..

But I got a new issue. On the code below, I cant get the list or UserContacts even if the realm has 3. Please help.

new Thread(new Runnable() {
@override
public void run() {
try {
// opens realm
realm = Realm.getDefaultInstance();
// get all userContacts
userContacts = realm.where(UserContact.class).findAll();
} finally {
if (realm != null) {
realm.close();
}
}
}
}).start();

So the 3 objects exist on the server side?
It might because of those changes haven't been downloaded locally.

The suggested way is to use notification listeners, see https://realm.io/docs/java/latest/#notifications

You can force downloading the latest version with SyncSession.downloadAllServerChanges(), but the RealmResults RealmChangeListener is a better option.

So, in this issue "E/REALM_SYNC: Connection[1]: Writing failed: End of input", what is the possible cause of this? It keeps on occuring in my console again :(

@jpabanil have you tried one of the options mentioned earlier?
1- using SyncSession.downloadAllServerChanges
or
2- using RealmChangeListener?

Yes I already did.. But still no data downloaded from realm server.

realm = Realm.getDefaultInstance();
realmListener = new RealmChangeListener() {
@Override
public void onChange(Object o) {
// get all userContacts
userContacts = realm.where(UserContact.class).findAll();
System.out.println(userContacts);
}
};
realm.addChangeListener(realmListener);

If I also add a UserContact object, here is the result..

I/System.out: [UserContact = proxy[{key:XGGPUA5RA2VP6},{contactCode:RA2VP6},{clientCode:CUF7SZZ},{eventCode:EVMEEVT},{exhibitorCode:XGGPUA5},{salutation:Mrs.},{firstName:Jessica},{middleName:Frieda},{lastName:Abate},{company:TTOC},{position:CEO},{address1:46455 Gilbert Ave},{address2:Suite 102},{city:Chilliwack},{province:BC},{postalCode:V2P 3V1},{country:Canada},{email:[email protected]},{phoneHome:(250) 374-8840},{phoneWork:(250) 374-0861},{phoneCell:(250) 318-7564},{notes:}]]

My question is, why there is a proxy? Also, the objects are not displayed in my ListView

"E/REALM_SYNC: Connection[1]: Writing failed: End of input",

For this issue, please first make sure the Realm Object Server is running, and the URL/port is correct. You can verify the server status by accessing http://<address>:<port>/health

My question is, why there is a proxy? Also, the objects are not displayed in my ListView

The log doesn't seem to be printed by Realm. Where did you get it? Can you show the full logcat trace?

In this question "My question is, why there is a proxy? Also, the objects are not displayed in my ListView", I tried to add UserContact object to realm and call this code

Realm.getInstanceAsync(Realm.getDefaultConfiguration(), new Realm.Callback() {
@Override
public void onSuccess(Realm realm) {
// get all userContacts
userContacts = realm.where(UserContact.class).findAll();
System.out.println(userContacts);
}
});

and the result is

I/System.out: [UserContact = proxy[{key:XGGPUA5RA2VP6},{contactCode:RA2VP6},{clientCode:CUF7SZZ},{eventCode:EVMEEVT},{exhibitorCode:XGGPUA5},{salutation:Mrs.},{firstName:Jessica},{middleName:Frieda},{lastName:Abate},{company:TTOC},{position:CEO},{address1:46455 Gilbert Ave},{address2:Suite 102},{city:Chilliwack},{province:BC},{postalCode:V2P 3V1},{country:Canada},{email:[email protected]},{phoneHome:(250) 374-8840},{phoneWork:(250) 374-0861},{phoneCell:(250) 318-7564},{notes:}]]
E/REALM_SYNC: Connection[1]: Writing failed: End of input
E/REALM_SYNC: Connection[1]: Writing failed: End of input
E/REALM_SYNC: Connection[1]: Writing failed: End of input
E/REALM_SYNC: Connection[1]: Writing failed: End of input
E/REALM_SYNC: Connection[1]: Writing failed: End of input (UNLIMITED)

OK, the proxy in the string is added by Realm object proxies. more info about it see https://realm.io/docs/java/latest/#faq-realmproxy

And according to the log, everything looks correct. The new UserContact you created has been added to Realm.

About why it is not showing in your ListView, there could be various reasons. But first thing i suggest is to play with our examples https://github.com/realm/realm-android-adapters/tree/master/example (I assume you are using realm-android-adapters)

Okay thanks for that.. But Why I cant download the objects from the realm object server? I can see that there are 3 UserContact in ROS but I cant see it on android?

Also, why I am getting this error "E/REALM_SYNC: Connection[1]: Writing failed: End of input" why I run the android app?

Can you share the core of creating SyncConfiguration?

This is the code...

SyncCredentials creds = SyncCredentials.usernamePassword(Constant.USER_NAME, Constant.PASSWORD, false);
        SyncUser.Callback<SyncUser> callback = new SyncUser.Callback<SyncUser>() {
            @Override
            public void onSuccess(SyncUser user) {
                SyncConfiguration config = new SyncConfiguration.Builder(user, Constant.REALM_URL)
                        .waitForInitialRemoteData()
                        .build();
                Realm.setDefaultConfiguration(config);
            }

            @Override
            public void onError(ObjectServerError error) {
                String errorMsg;
                switch (error.getErrorCode()) {
                    case UNKNOWN_ACCOUNT:
                        errorMsg = "Account does not exists.";
                        break;
                    case INVALID_CREDENTIALS:
                        errorMsg = "User name and password does not match";
                        break;
                    default:
                        errorMsg = error.toString();
                }
                System.out.println(errorMsg);
            }
        };

        SyncUser.loginAsync(creds, Constant.AUTH_URL, callback);
  1. What are the Constant.REALM_URL and Constant.AUTH_URL?
  2. Can you access the URL http://<Constant.REALM_URL>/health from the testing devices?
  3. Has onSuccess() been called?

1) Below are the values:

public static final String AUTH_URL = "http://" + OBJECT_SERVER_IP + ":9080/auth";
public static final String REALM_URL = "realm://" + OBJECT_SERVER_IP + ":9080/~/" + REALM_NAME

2) It says {"error": "Unauthorized"}

3) And yes, onSuccess() is called.. I can even print in console from that method.

can you post the server side log here as well?

and which version of Realm Object Server are you using?

Below are the latest...

sync: HTTP Connection[2851]: Connection is closed after HTTP response.
sync: HTTP Connection[2851]: Connection from 127.0.0.1:59678

and which version of Realm Object Server are you using? v1.8.3

4.0.0 (2017-10-16)

Breaking Changes

The internal file format has been upgraded. Opening an older Realm will upgrade the file automatically, but older versions of Realm will no longer be able to read the file.

  • [ObjectServer] Updated protocol version to 22 which is only compatible with Realm Object Server >= 2.0.0.

The realm-java 4.x isn't compatible with ROS 1.x.x. Please use ROS 2.0.11 (the latest right now) instead.

So what realm-java version do I need to use?

you can use realm-java 4.1.1 and Realm-Object-Server 2.0.11 which are both the latest right now.

Should I used this "classpath "io.realm:realm-gradle-plugin:3.7.2"" instead?

It is strongly recommended to update both realm-java and realm-object-server to the latest version.

but Im not the owner of the ROS.. I am just working on the android app..

Then you can use 3.7.2 for now. But you have to update the ROS sooner or later since we won't support the old version anymore.

Thanks for that version 3.7.2, I was able to download that objects now.. But still its not displaying on my listView :(

Oh, I was able to display it now 馃憤 Thanks for the help :)

Was this page helpful?
0 / 5 - 0 ratings