Firebase RealtimeDatabase现在无法运行?

时间:2017-10-14 08:56:53

标签: android ios firebase firebase-realtime-database

现在Firebase RealtimeDatabase"写"现在正在工作。

这是firebase示例代码。

FirebaseDatabase database = FirebaseDatabase.getInstance();
        DatabaseReference myRef = database.getReference("message");

        myRef.setValue("Hello, World!");

        myRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                // This method is called once with the initial value and again
                // whenever data at this location is updated.
                String value = dataSnapshot.getValue(String.class);
                Log.d(TAG, "Value is: " + value);
            }

            @Override
            public void onCancelled(DatabaseError error) {
                // Failed to read value
                Log.w(TAG, "Failed to read value.", error.toException());
            }
        });

ValueEventListener' onDataChange被调用,但我无法在firebase控制台的实时数据库中找到写入的数据。

此外,之前制作的使用实时数据库的应用程序今天没有表现。

这是firebase的错误吗? 我现在能做什么?

PS:这是日志消息。

10-14 18:19:52.730 15916-15916/com.example.star_man.firebaserealtimedatabase V/FA: onActivityCreated
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: Do partial code cache collection, code=61KB, data=47KB
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: After code cache collection, code=61KB, data=47KB
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: Increasing code cache capacity to 256KB
10-14 18:19:55.549 15916-15935/com.example.star_man.firebaserealtimedatabase I/art: Starting a blocking GC Instrumentation
10-14 18:19:56.858 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Using measurement service
10-14 18:19:56.860 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Connecting to remote service
10-14 18:19:56.872 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Activity resumed, time: 5619167420
10-14 18:19:56.876 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: ThreadedRenderer.create() translucent=false
10-14 18:19:56.884 15916-15916/com.example.star_man.firebaserealtimedatabase D/InputTransport: Input channel constructed: fd=80
10-14 18:19:56.886 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: setView = DecorView@304ed89[MainActivity] touchMode=true
10-14 18:19:56.905 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: dispatchAttachedToWindow
10-14 18:19:56.949 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2560] result=0x27 surface={isValid=true 525456977920} surfaceGenerationChanged=true
10-14 18:19:56.951 15916-15982/com.example.star_man.firebaserealtimedatabase D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1440x2560]-format:1
10-14 18:19:56.951 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: mHardwareRenderer.initialize() mSurface={isValid=true 525456977920} hwInitialized=true
10-14 18:19:56.981 15916-15970/com.example.star_man.firebaserealtimedatabase D/FA: Connected to remote service
10-14 18:19:56.981 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Processing queued up service tasks: 1
10-14 18:19:57.033 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
10-14 18:19:57.033 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
10-14 18:19:57.035 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 525456977920}
10-14 18:19:57.038 15916-15916/com.example.star_man.firebaserealtimedatabase V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@eceb89a nm : com.example.star_man.firebaserealtimedatabase ic=null
10-14 18:19:57.038 15916-15916/com.example.star_man.firebaserealtimedatabase I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
10-14 18:19:57.051 15916-15916/com.example.star_man.firebaserealtimedatabase D/InputTransport: Input channel constructed: fd=85
10-14 18:20:01.990 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Inactivity, disconnecting from the service

2 个答案:

答案 0 :(得分:1)

尝试使用OnComplete Listener,它是否被调用?

myRef.setValue("Hello, World!", new DatabaseReference.CompletionListener() {
  @Override
  public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
    if (databaseError != null) {
        Log.d("saving","Data could not be saved " + databaseError.getMessage());
    } else {
        Log.d("saving","Data saved successfully.");
    }
  }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
        Log.e("saving","Saving failed: " + e.getMessage());
    }
});

答案 1 :(得分:1)

原因是我们公司的防火墙。但我不知道为什么调用onDataChange回调函数。 我认为应该调用onCancelled回调函数。

无论如何,我修改了防火墙规则,现在它运行良好。