I am setting up a watch for a query in Firestore in my local PC using Java admin SDK. If the network disconnects and reconnects then the updates are no longer received by my local machine. I have observed that if the network reconnection happens within a short interval (< 2 - 3 mins) then it is fine. But if it is longer then this issue happens. Also, no error/exception is notified in the Listener callback so that I can set up a watch again for the updates. My PC is not behind a proxy so it cannot be a proxy issue.
Please help me in debugging this issue.
Edit:
Looks like this is a bug in the SDK. I enabled the SDK logs and tried the following experiments:
Scenario 1:
- Watch for query updates
- Client sets up a GRPC connection with the server.
- Looks like server is sending a keep alive(?) every minute to the client but no keep alive from the client to server
- Disconnect the network
- Reconnect within a minute, the query connection is still active and document updates arrive as expected
- Disconnect the network
- Reconnect after 5 minutes
- Here my guess is that the server would have reset the GRPC connection from its end since it cannot reach the client but the SDK doesn't know about this. It is still expecting server to send the keep alive.
- No document updates are received at the client side (as expected)
- Issue a new query and watch for its updates.
- SDK tries to send the query over the same GRPC connection it had established earlier, realizes that the connection is closed, opens a new GRPC connection. Now the document updates start coming for both the queries.
Scenario 2:
- Watch for query updates
- Disconnect the network for about 5 minutes
- Issue a new query before the network is reconnected.
- SDK tries to send the query over the same GRPC connection it had established earlier, realizes that the connection is closed, opens a new GRPC connection. Even this fails but the connection attempt is retried every minute.
- Reconnect the network.
- Connection attempt of SDK succeeds and the updates start coming for both the queries.