firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.27k stars 574 forks source link

".info/connected" throwing isConnected False with good network connection #1713

Closed raj050793 closed 4 years ago

raj050793 commented 4 years ago

".info/connected" throwing isConnected False with a good network connection and happening with very less users and surprisingly issue resolved automatically after some time but sometimes issue persists for more than 24 hours. Firestore also throwing error "Client is offline". I know this issue is because of network state but all other things are working fine where network is require.

2020-06-25 01:22:41.059 10997-11827/com.alignit.checkers W/Firestore: (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds

This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
google-oss-bot commented 4 years ago

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

wu-hui commented 4 years ago

Hi raj050793,

Thanks for reporting this issue.

We'd need a bit more information to be able to help though. It looks like your app is running on instable network environment, and you said other things are working fine while firestore is logging warnings. But maybe firestore happens to be the one that is working with a network at that time. Do you see the reverse happens: when other apps reporting warnings but firestore works?

Also, we really need information like OS/SDK version, network setup, etc to be able to look further. Your problem description as is now is not actionable.

Thanks

raj050793 commented 4 years ago

Hi wu-hui, No, reverse never happens, always happening with firestore and realtime data base. I am also logging firebase analytics where I Check google is available or not and maximum cases google is available

public static boolean isGoogleAvailable() { try { Socket socket = new Socket(); InetSocketAddress socketAddress = new InetSocketAddress(HOST_GOOGLE, 80); socket.connect(socketAddress, 5000); return true; } catch (UnknownHostException unknownHost) { SDKLoggingHelper.logException(SDKNetworkHelper.class.getSimpleName(), unknownHost); return false; } catch (Exception e) { SDKLoggingHelper.logException(SDKNetworkHelper.class.getSimpleName(), e); return false; } }

when the "offline error occurs" 70% times isGoogleavailable returns true. (based on firebase analytics events)

SDK info - implementation 'com.google.firebase:firebase-auth:19.3.1' implementation 'com.google.firebase:firebase-core:17.4.3' implementation 'com.google.firebase:firebase-database:19.3.1' implementation 'com.google.firebase:firebase-firestore:21.4.3' implementation 'com.google.firebase:firebase-functions:19.0.2'

OS - Today itself i face this issue in nokia 6.1 device (Android Version 10)

ashwinraghav commented 4 years ago

".info/connected" throwing isConnected False with a good network connection and happening with very less users and surprisingly issue resolved automatically after some time but sometimes issue persists for more than 24 hours.

Please consider https://github.com/firebase/firebase-android-sdk/issues/1614#issuecomment-638985777 This could explain why you see this when you are actually connected. Does your application logic put a subset of your clients into a situation where they are not listening to any node?

2020-06-25 01:22:41.059 10997-11827/com.alignit.checkers W/Firestore: (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds

This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

Is this related to your previous observation about .info/connected too or are you seeing this independently?

raj050793 commented 4 years ago

Hi ashwin, .info/connected is just for reference I ve registered ValueEventListener but either onDataChange or onCancelled not getting called in this case. I am sharing a sample code from my project. `private void createSharableRoom(final View waitingRoomView, final View loaderView, final List prevIds) { String roomId = generateRoomId(); while (prevIds.contains(roomId)) { roomId = generateRoomId(); } final String selectedRoomId = roomId; SDKRemoteDatabaseHelper.getSharedMatchRoomRef(roomId).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { if (!dataSnapshot.exists()) { SDKAnalyticsCommon.sendCustomEvent(SelectOpponentActivity.this, "UniqueRoomId", "UniqueRoomId", "UniqueRoomId" + prevIds.size(), "UniqueRoomId_" + prevIds.size()); waitingRoomView.findViewById(R.id.cl_share).setVisibility(View.VISIBLE); sharingRoomCreator.createRoom(selectedRoomId); prevIds.add(selectedRoomId); loaderView.setVisibility(View.GONE); rootView.removeView(loaderView); } else { createSharableRoom(waitingRoomView, loaderView, prevIds); } }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {
            onFail();
        }
    });

}_`
raj050793 commented 4 years ago

2020-06-25 01:22:41.059 10997-11827/com.alignit.checkers W/Firestore: (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds

This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

.info/connected and above log can be interconnected and happening together. but I can't find logs for Firebase/Realtimedatabase

raj050793 commented 4 years ago

https://stackoverflow.com/questions/60961181/failed-to-get-document-because-the-client-is-offline I am facing exactly same issue mentioned in this StackOverflow thread

ashwinraghav commented 4 years ago

https://stackoverflow.com/questions/60961181/failed-to-get-document-because-the-client-is-offline

If it is the same issue. The solution is what I have proposed. You may not have a listener on any node in the collection. I sense this may be a problem better suited for support or firebase-talk. Please reach us through those channels to get better help.

raj050793 commented 4 years ago

I have tried on the firebase bug report page but didn't get any help. Please try to understand I am using firebase realtime database and cloud firestore for online multiplayer for 7 games with 600k+ daily active users. and this is happening with some users for some finite time so you can't say that I may not have a listener on any node in the collection.