6

In my application, I am using google firebase real-time database with admin-sdk for Java. When I run a sample program from my machine it works perfectly and updates the given data into firebase db. But, when I try to run the same program from another public server, it's not working. It doesn't throw any exceptions at all. updateChildren() was executed, and then nothing. I tried with onCompletionListener too.There is nothing in there. What might be the problem?

FBManager.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();
        }
    }
}
karthi keyan
  • 213
  • 2
  • 19
Sivanandham
  • 135
  • 9
  • The Firebase server has no knowledge about what machine you're using to access it. So the first thing that comes to mind is that the client is being rejected based on authentication/authorization. Did you copy `key/siva-6d0aa-firebase-adminsdk-1bo0t-e98c5af5d5.json` to the other machine? – Frank van Puffelen Apr 06 '18 at 14:00
  • Yes..! Am using the same json key file in both places.. Actually there is another application which is creatiing data into the same db, which is working fine. – Sivanandham Apr 09 '18 at 06:02
  • It seems most likely that the traffic from the non-functioning machine is somehow blocked. You might want to check the debug logs after [enabling debug logging](https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/database/FirebaseDatabase.html#setLogLevel(com.google.firebase.database.Logger.Level)), or see if you can access the database from https://www.firebase.com/test.html. – Frank van Puffelen Apr 09 '18 at 14:09
  • Thanks for your suggestions Frank. I am able to access the database from test.html. For the blocking part, I tested the from another server (public) from same data center without much luck. The same issue occurs. – Sivanandham Apr 11 '18 at 06:15
  • 2
    It seems this is to do with server network issue. Working fine in another server. Thanks for the help @FrankvanPuffelen . – Sivanandham Apr 27 '18 at 06:36

1 Answers1

-1

It seems this is to do with server network issue. Working fine in another server. Closing this question. thanks

Sivanandham
  • 135
  • 9