Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore listeners stop receive updates - Java #896

Open
lucazin opened this issue Dec 21, 2023 · 8 comments
Open

Firestore listeners stop receive updates - Java #896

lucazin opened this issue Dec 21, 2023 · 8 comments
Assignees

Comments

@lucazin
Copy link

lucazin commented Dec 21, 2023

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?

@google-oss-bot
Copy link

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

@lucazin
Copy link
Author

lucazin commented Dec 24, 2023

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.

@lucazin lucazin changed the title Firestore client stops functioning after 10 snapshot listeners are registered - JAVA Firestore listeners stop receive updates - Java Dec 24, 2023
@prateekrai1
Copy link

Can I work on this issue?

@cherylEnkidu
Copy link

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?

@lucazin
Copy link
Author

lucazin commented Jul 24, 2024

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!

@cherylEnkidu
Copy link

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!

@lucazin
Copy link
Author

lucazin commented Jul 28, 2024

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.

@cherylEnkidu
Copy link

Hi @lucazin ,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants