在SpringBoot中,Firebase连接在Linux上不起作用

我想要实现的是打开一个连接到我的firebase数据库,并获得一些我需要解析的数据。 我正在使用Spring Boot框架,firebase,kotlin和gradle的admin sdk。 在Windows 10上,它是像预期的那样工作,但是当我尝试在我的Linux服务器上运行.jar文件时,它不会得到任何数据或错误。 它被困在ValueEventListener中。 我有ufw安装,但禁用它或添加端口5228:5230(tcp / udp),没有解决问题。

val dataMinifiedRef = database.reference.child("minifiedData").child("areas") dataMinifiedRef.addListenerForSingleValueEvent(object : ValueEventListener { override fun onCancelled(error: DatabaseError?) { log.info(error!!.message) } override fun onDataChange(dataSnapshot: DataSnapshot) { log.info("Got data") } }) 

编辑:这是我解析服务帐户。

  val str = "{\n" + ... "}\n" // convert String into InputStream val serviceAccount = ByteArrayInputStream(str.toByteArray()) val options = FirebaseOptions.Builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) .setDatabaseUrl("https://xxx.firebaseio.com") .build() 

我得到以下错误。

 Tue Dec 19 15:31:41 CET 2017 [DEBUG] com.google.firebase.database.connection.PersistentConnection‌​: pc_0 - Trying to fetch auth token Tue Dec 19 15:31:41 CET 2017 [DEBUG] com.google.firebase.database.connection.PersistentConnection‌​: pc_0 - Error fetching token: java.io.IOException: Error getting access token for service account: 

问题是我们的Linux服务器上的时间不是自动同步的。 我已经find了这篇文章 ,他提到了解决方案。 然后,我遵循本指南并添加了与我们的服务器位置相同的NTP服务器。