Basic firebase Java connection

I tried to establish a basic connection with firebase in a Java application, and I couldn't get any response at all using the basic code provided

This is the code I'm using:

package fix;

import com.firebase.client.*;

public class Main {

  public static void main(String args[]) throws Exception {

    String url = "https://----.firebaseIO.com/";
    Firebase dataRef = new Firebase(url);

    dataRef.addListenerForSingleValueEvent(new ValueEventListener() {
         @Override
         public void onDataChange(DataSnapshot snapshot) {
             System.out.println("data");
         }

         @Override
         public void onCancelled() {
             System.err.println("Listener was cancelled");
         }
    });

    System.out.println("hi");
  }
}

The library seems well installed Any suggestions?

to update

[java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Raising events for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Doing onDiff with changes: []
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Raising events for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Doing onDiff with changes: []
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Adding Value Event Listener callback for path: /
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] PersistentConnection: pc_0 - Listening on / for [{}]
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] PersistentConnection: pc_0 - Adding listen params: [{}]
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] EventRaiser: Raising 0 event(s)
 [java] wait
 [java] wait
 [java] wait
 [java] wait

Solution

Firebase engineers are here. Can you enable logging and publish output? You can enable logging by doing the following

Firebase.getDefaultConfig().setLogLevel(Logger.Level.DEBUG);

In addition, can you add observers?

dataRef.child(".info/connected");

And record the events you get from it? This will tell you when to connect or disconnect from firebase

Editor: This is solved by E - mail This is an error in the client library and has now been resolved You can download the latest version from the website: https://www.firebase.com/docs/downloads.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>