-1

Its a very weird issue with Firebase. I am calling setValue() on a Firebase node and then expecting OnComplete callback function to be called, which is never being called on a particular internet connection. Other firebase queries are also not working on that particular WiFi,

individualUserNode.setValue(user, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {

            if (databaseError == null) {
                EventBus.getDefault().post(new MyEvents.UserSaved(true));
            } else {
                EventBus.getDefault().post(new MyEvents.UserSaved(false));
            }

        }
    });
satish123
  • 541
  • 7
  • 25

1 Answers1

0

That's expected. The listener only fires once the server acknowledges the request:

This interface is used as a method of being notified when an operation has been acknowledged by the Database servers and can be considered complete

SUPERCILEX
  • 3,929
  • 4
  • 32
  • 61
  • Thanks SUPERCILEX. But, shouldn't there be an error callback (when it's timed out or any error has occurred) ? – satish123 Sep 26 '17 at 07:33
  • Nope, unfortunately not. The error is for the case where your rules denied the write, not some offline error. https://stackoverflow.com/a/37190184/4548500 I would recommend adding a value event listener instead of a write complete listener. – SUPERCILEX Sep 26 '17 at 14:52