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 client stops functioning after 10 snapshot listeners are registered - JAVA #1511

Open
lucazin opened this issue Dec 21, 2023 · 11 comments
Labels
api: firestore Issues related to the googleapis/java-firestore API.

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

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..

image

Can someone help me?

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

image

now.. 7 listeners and loss 1 and after 7 again..

the problem is stop working some principal listeners.

Im trying to do this

dbfirestore = FirestoreClient.getFirestore();
dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder()
.setPoolSize(2).build());

@meltsufin meltsufin transferred this issue from googleapis/google-cloud-java Dec 21, 2023
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/java-firestore API. label Dec 21, 2023
@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

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.

  • Java

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

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

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

if we change te firestore instance to this line

dbfirestore = FirestoreClient.getFirestore();
dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder()
.setPoolSize(2).build());

            will change something? 

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

image

@gregfenton
Copy link

Can you describe the execution environment? Is this running in an EC2 container or something?

Are there any exceptions in the Java logs?

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

Lets Go.

No exception, just stop listening..

Im running a API in SpringBoot inside a EC2 Linux ( Normal Java Application API) work like a charm no problem with the api.
I have added firebase admin in dependecy gradle (like google said)
I have the credentials by service account, like google explain.

The realtime database work good! firestore work too but some times the listener drop, i know because the document is not deleted from collection and not saving in database inside API.

This is NOT expected behavior because listener drop and not delete other 500 messages.. its not equals count read, write, delete..

image

This is right EXPECTED behavior, because listener is active, read, process and delete ..

image

I have 7 listeners and this is expected, not drop

image

But this behavior is not expected

image
image

I will try to put this code and check if resolve something, i will set pool size 2.. but i thinks is not necessary.. we talking about 7 listeners only..

dbfirestore = FirestoreClient.getFirestore();
dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder()
.setPoolSize(2).build());

im glad someone can help me resolve my problem with firestore.

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

i did now a stress work load...
i send a lot request to a specific listener and this is the behavior.

Drop a lot os listeners.. @gregfenton i have to restart the server to back the listeners again..

if i have a higher workload.. firestore drop the listener..

image

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

@schmidt-sebastian @lanbochen is related with this issue? ( the difference is nodejs to java )

firebase/firebase-admin-node#931

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

image

i change my code just to check the workload.

for(int i=0;i<=50;i++)
new DBFireStore().SendOrdersTransport(onFinishedListener,context,orderItens);

 my listener drop after run this..  i put for just to see ..but original code dont have..  but when users are send orders in high scale happen the same thing.. 

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

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.. :(

@lucazin
Copy link
Author

lucazin commented Dec 21, 2023

im using this

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

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

@gregfenton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/java-firestore API.
Projects
None yet
Development

No branches or pull requests

2 participants