scala - Firebase Java SDK doesn't persist data and doesn't trigger callback. Tasks seems never complete -


i'm trying write data on firebase based on guide https://firebase.google.com/docs/database/server/start , using play framework + scala.

after call databasereference.setvalue nothing happens: data isn't persisted on firebase , callback not triggered.

here's code:

  lazy val conf = configfactory.load()    lazy val options = new firebaseoptions.builder()                                         .setcredential(firebasecredentials.fromcertificate(new fileinputstream(conf.getstring("firebase.credentials.path"))))                                         .setdatabaseurl("https://orsz-xxxxx-xxxxx.firebaseio.com/")                                         .build()    lazy val propsdb = firebasedatabase.getinstance().getreference()    /** initialize block instantiates firebaseapp **/   {     println("[firebasepersistence] - initialize firebaseapp")     firebaseapp.initializeapp(options)     firebasedatabase.getinstance().setloglevel(logger.level.debug)     println("[firebasepersistence] - initialize firebaseapp done!")   }    def persistproposition(prop: proposition): future[proposition] = future {     val task = propsdb.setvalue(1, new databasereference.completionlistener() {       override def oncomplete(databaseerror: databaseerror, databasereference: databasereference) {         if (databaseerror != null) {           println("error: " + databaseerror.getmessage)         } else {           println("[firebasepersistence.persistproposition] - ok")         }       }     })     prop   } 

i can see, testing on sbt console, task generated on setvalue never completes after seconds:

scala> task.iscomplete  res6: boolean = false 

executing firebase log level debug log:

thu apr 06 08:53:37 brt 2017 [debug] persistentconnection: pc_0 - trying fetch auth token thu apr 06 08:53:37 brt 2017 [debug] repooperation: set: / thu apr 06 08:53:37 brt 2017 [debug] dataoperation: set: / 1 thu apr 06 08:53:37 brt 2017 [debug] repooperation: aborting transactions path: /. affected: / thu apr 06 08:53:38 brt 2017 [debug] persistentconnection: pc_0 - fetched token, opening connection thu apr 06 08:53:38 brt 2017 [debug] connection: conn_0 - opening connection thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - websocket opened thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - reset keepalive thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - ws message: {"t":"c","d":{"t":"h","d":{"ts":1491479619239,"v":"5","h":"s-usc1c-nss-135.firebaseio.com","s":"bxe2hqcxtnns4eznao5xjwsinnipu5fi"}}} thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - reset keepalive. remaining: 44991 thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - handlenewframecount: 1 thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - handleincomingframe complete frame: {t=c, d={t=h, d={h=s-usc1c-nss-135.firebaseio.com, s=bxe2hqcxtnns4eznao5xjwsinnipu5fi, v=5, ts=1491479619239}}} thu apr 06 08:53:39 brt 2017 [debug] connection: conn_0 - got control message: {t=h, d={h=s-usc1c-nss-135.firebaseio.com, s=bxe2hqcxtnns4eznao5xjwsinnipu5fi, v=5, ts=1491479619239}} thu apr 06 08:53:39 brt 2017 [debug] connection: conn_0 - realtime connection established thu apr 06 08:53:39 brt 2017 [debug] persistentconnection: pc_0 - onready thu apr 06 08:53:39 brt 2017 [debug] persistentconnection: pc_0 - handling timestamp thu apr 06 08:53:39 brt 2017 [debug] persistentconnection: pc_0 - sending first connection stats thu apr 06 08:53:39 brt 2017 [debug] connection: conn_0 - sending data: {t=d, d={a=s, r=0, b={c={sdk.java.3-0-0=1}}}} thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - reset keepalive. remaining: 44993 thu apr 06 08:53:39 brt 2017 [debug] persistentconnection: pc_0 - calling restore state thu apr 06 08:53:39 brt 2017 [debug] persistentconnection: pc_0 - restoring auth. thu apr 06 08:53:39 brt 2017 [debug] connection: conn_0 - sending data (contents hidden) thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - reset keepalive. remaining: 44996 thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - ws message: {"t":"d","d":{"r":0,"b":{"s":"ok","d":""}}} thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - reset keepalive. remaining: 44836 thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - handlenewframecount: 1 thu apr 06 08:53:39 brt 2017 [debug] websocket: ws_0 - handleincomingframe complete frame: {t=d, d={r=0, b={d=, s=ok}}} thu apr 06 08:53:39 brt 2017 [debug] connection: conn_0 - received data message: {r=0, b={d=, s=ok}} thu apr 06 08:53:40 brt 2017 [debug] websocket: ws_0 - ws message: {"t":"d","d":{"r":1,"b":{"s":"permission_denied","d":"access denied."}}} thu apr 06 08:53:40 brt 2017 [debug] websocket: ws_0 - reset keepalive. remaining: 43628 thu apr 06 08:53:40 brt 2017 [debug] websocket: ws_0 - handlenewframecount: 1 thu apr 06 08:53:40 brt 2017 [debug] websocket: ws_0 - handleincomingframe complete frame: {t=d, d={r=1, b={d=access denied., s=permission_denied}}} thu apr 06 08:53:40 brt 2017 [debug] connection: conn_0 - received data message: {r=1, b={d=access denied., s=permission_denied}} thu apr 06 08:53:40 brt 2017 [debug] persistentconnection: pc_0 - authentication failed: permission_denied (access denied.) thu apr 06 08:53:40 brt 2017 [debug] connection: conn_0 - closing realtime connection thu apr 06 08:53:40 brt 2017 [debug] websocket: ws_0 - websocket being closed thu apr 06 08:53:40 brt 2017 [debug] persistentconnection: pc_0 - got on disconnect due other thu apr 06 08:53:40 brt 2017 [debug] persistentconnection: pc_0 - scheduling connection attempt thu apr 06 08:53:40 brt 2017 [debug] connectionretryhelper: scheduling retry in 821ms thu apr 06 08:53:41 brt 2017 [debug] websocket: ws_0 - closed thu apr 06 08:53:41 brt 2017 [debug] persistentconnection: pc_0 - trying fetch auth token thu apr 06 08:53:41 brt 2017 [debug] persistentconnection: pc_0 - fetched token, opening connection 

i can see permission denied on log can't figure out why.

i test credentials on fileinputstream , ok.

the permission on firebase project:

{   "rules": {     ".read": "true",     ".write": "true"   } } 

i test using firebase-admin-4.1.6 , firebase-server-sdk-3.0.1 , have same result

edit: printed firebaseapp, firebasedatabase , databasereference objets before call setvalue , got lines above. how may ensure admin sdk initialized correctly?

firebaseapp=firebaseapp{name=[default], options=firebaseoptions{databaseurl=https://orsz-xxxxx-xxxxx.firebaseio.com/, credential=com.google.firebase.auth.firebasecredentials$certcredential@558b77e8, databaseauthvariableoverride={}}} firebaseapp.name=[default]  firebasedatabase.getinstance()=com.google.firebase.database.firebasedatabase@124cb42b  databasereference=https://orsz-xxxxx-xxxxx.firebaseio.com/12345 

i tested new project , admin sdk version 4.1.6.

with java code:

final firebasedatabase database = firebasedatabase.getinstance(); databasereference ref = database.getreference("43256111"); ref.setvalue(1, new databasereference.completionlistener() {     @override     public void oncomplete(databaseerror databaseerror, databasereference databasereference) {         if (databaseerror != null) {             system.err.println(databaseerror);         } else {             system.out.println("written");         }     } }); 

the 43256111 location in database used testing.

i after few seconds:

written

the rules don't matter in case, since admin sdk runs administrative privileges by-passes these rules me:

"43256111": {   ".write": false } 

so i'm not sure what's going on in case, can't reproduce it. sure have admin sdk initialized correctly?


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -