firebase / firebase-admin-java

Firebase Admin Java SDK

Home Page:https://firebase.google.com/docs/admin/setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Firestore listeners stop receive updates - Java

lucazin opened this issue · comments

Java Spring Boot 3.0.2
Firestore Listeners ( 7 )
Region FireStore - Sao paulo
Region Server - Sao Paulo AWS
Issue related : googleapis/google-cloud-java#3514
googleapis/java-firestore#1511

I have this kind of problem @schmidt-sebastian

i have 7 listeners, but always disconnecting some listeners and stop registering information in database. Im using Java.

What i have to do..to stop this behavior..?? because its intermitent situation.

I have to move to realtime database? or have some config extra to fix that? Because when i restart the server the listener back again..

Again, we are having a strange behavior of listeners. We have 7 listeners active and some time just 6..just 5.. and back to 7 ..but with this behavior we can put our plataform in production stage.

im using this

https://firebase.google.com/docs/admin/setup#java

implementation 'com.google.firebase:firebase-admin:9.2.0'

##########################

Resource resource = resourceLoader.getResource("classpath:prod-firebase.json");
    String fileLines = new BufferedReader(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))
            .lines()
            .collect(Collectors.joining());
    InputStream serviceAccount = new ByteArrayInputStream(fileLines.getBytes());

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setCredentials(GoogleCredentials.fromStream(serviceAccount))
            .setDatabaseUrl("realtimedatabaseurl") //we are using realtimedatabase 
            .build();
    FirebaseApp.initializeApp(options);

    databaseReference = FirebaseDatabase.getInstance().getReference();

    dbfirestore = FirestoreClient.getFirestore(); // firestore instance

image

image

the problem is higher workload .. i check three times the workload and if we see the listener drop when the workload if high. the clock below each graph show us.. everytime have a peak drop listener.

now..i dont know what to do.. :(

Can someone help me?

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Hello everyone!
Merry chrismas to all!

Today in the morning we face this issue again.. the listener stop listen updates until i restart the server.
How can i fix this?

`Resource resource = resourceLoader.getResource("classpath:firebase.json");
String fileLines = new BufferedReader(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining());
InputStream serviceAccount = new ByteArrayInputStream(fileLines.getBytes())

    InstantiatingGrpcChannelProvider channelProvider =
            InstantiatingGrpcChannelProvider.newBuilder()
                    .setKeepAliveTime(Duration.ofSeconds(60L))
                    .setKeepAliveTimeout(Duration.ofMinutes(5L))
                    .setPoolSize(5)
                    .build();
    FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder()
            .setChannelProvider(channelProvider).build();

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setCredentials(GoogleCredentials.fromStream(serviceAccount))
            .setDatabaseUrl("https://rtdb-url.firebaseio.com/")
            .setFirestoreOptions(firestoreOptions)
            .build();
    FirebaseApp firebaseApp =FirebaseApp.initializeApp(options,"websocket");   
    this.resourceLoader = resourceLoader;
    dbfirestore = FirestoreClient.getFirestore(firebaseApp);

`

i have 6 listeners, but in firestore graph show 7.. some times 5 or 8... this is very strange and causing big problems to our applications.. and stop random listener...so a order listener or billing listener stop ...we have a big problem..

@schmidt-sebastian can you help us please we are stuck in this situation.

Can I work on this issue?

Hi @lucazin ,

Sebastian is not long working inside the team, could you please let me know if you are still experiencing this issue when upgrade to the latest version of Java admin SDK?

Hello!

Yes I'm still facing this problem with firestore.

The only workaround was stop using and back to real-time database because firestore was detach listeners in my springboot application after some time and gives me a big problem, because when listerner stop I can receive real-time update and all data inside firestore still blocked because my springboot can't consume this data because listener was down.

Thanks!

Hi @lucazin ,

I tried to reproduce this problem on my side but everything works fine. Could you provide us a minimum repo app and enable the debug log?

Thank you!

Did you try create a simple springboot server app.

And attach more than 5 listeners same time?

Unfortunately the repo is private production app..

But simple logic is, listening 5 paths in firestore to receive demands information.

after a while the listener is not alive anymore and for working again have to restart.

Running in aws ec2.

Hi @lucazin ,

Unfortunately we cannot further investigate without a repo. Can you try it without springboot to see if it is working?