Google Firebase实时数据库updateChildren()方法不起作用? [关闭]

问题描述 投票:6回答:1

在我的应用程序中,我使用google firebase实时数据库和admin-sdk for Java。当我从我的机器上运行一个示例程序时,它可以很好地工作并将给定的数据更新到firebase db中。但是,当我尝试从另一个公共服务器运行相同的程序时,它不起作用。它根本不会抛出任何异常。 updateChildren()被执行,然后什么都没有。我也试过onCompletionListener。那里什么都没有。可能是什么问题?

FB manager.Java

import com.nexge.firebase.Firebase;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import java.util.HashMap;

class FBManager {
    //FIREBASE
    public static Firebase fireBase;
    public static DatabaseReference dbRef = null;
    public static String filePath="key/siva-6d0aa-firebase-adminsdk-1bo0t-e98c5af5d5.json";
    public static String databaseUrl="https://siva-6d0aa.firebaseio.com";
    public static String projectName="ABES";
    public static String databaseChildPath;

    public static void main(String[] args) {
        try {
            databaseChildPath="calls/";
            System.out.println("Inside iniDB !");
            fireBase = new Firebase(filePath, databaseUrl, projectName, databaseChildPath);
            System.out.println("FireBase db created!");
            dbRef = fireBase.getDatabaseReference();
            System.out.println("Got reference!");
            T t = new T();
            new Thread(t).start();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}

T.Java

class T implements Runnable {
    public void run() {
        try {
            String path = "191963944/5e0e44e2-3442-4acd-977a-fea7232c0f0a";
            HashMap hm1 = new HashMap();
            hm1.put("caller_Recv_Media_IpPort","xxx.xxx.xx.xxx:9811");
            HashMap hm2 = new HashMap();
            hm2.put("yServer_src_Media_IpPort","xxx.xx.xx.xx:10000");
            FBManager.dbRef.child(path).updateChildren(hm1);
            FBManager.dbRef.child(path).updateChildren(hm2);
            Thread.sleep(10000);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
java firebase firebase-realtime-database firebase-admin
1个回答
0
投票

这似乎与服务器网络问题有关。在另一台服务器上正常工作结束这个问题。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.