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

The app doesn't detect it is online with Wi-Fi only connexion #3480

Closed
CharlesNepote opened this issue Aug 25, 2020 · 19 comments · Fixed by #3519
Closed

The app doesn't detect it is online with Wi-Fi only connexion #3480

CharlesNepote opened this issue Aug 25, 2020 · 19 comments · Fixed by #3519
Labels
Android 7 Android Nougat related issues and feature requests bug Produces incorrect or unexpected result or behaviour. network P1 candidate P1
Milestone

Comments

@CharlesNepote
Copy link
Member

Describe the bug

  • Samsung Galaxy A5 (2016)
  • Android 7.0
  • No SIM card in the phone but wifi activated and internet connection ok

I'm online (see video where I open firefox and open a link in Wikipedia), and then, when scanning a product with Open Food Facts beta 3.4.3, it tells the phone is offline.

Video
https://drive.google.com/file/d/11nOI72uwagYGm5Bc1cFCD6rcXuKyXTwl/view?usp=sharing

@teolemon teolemon changed the title Doesn't detect online The app doesn't detect it is online with Wi-Fi only connexion Aug 25, 2020
@teolemon teolemon added network bug Produces incorrect or unexpected result or behaviour. labels Aug 25, 2020
@teolemon
Copy link
Member

teolemon commented Aug 25, 2020

This is related to the revamp of offline product addition by @philippeauriach (we went from 2 modes to one mode) and possibly a revamp by @VaiTon .
The relevant function is below, but we shouldn't fail on that. It might be related to a bad network. Is it reproducible many times ?
https://github.com/openfoodfacts/openfoodfacts-androidapp/blob/develop/app/src/main/java/openfoodfacts/github/scrachx/openfood/utils/Utils.java#L523

@teolemon teolemon added this to the v3.4.2 milestone Aug 25, 2020
@CharlesNepote
Copy link
Member Author

Is it reproducible many times ?

Yes, every time. I can't get any product. The product do exists in the database.

@teolemon
Copy link
Member

Ok, eventually this will be fixed even better by the offline mode (so that we don't accidentally add products that are already present, because of offline mode).
Meanwhile, you tell me you have a good and stable connexion, so it might either be:

  • Samsung specific network behavior
  • Android 7 specific network behavious
  • a programming mistake on our side when only wifi is available and no sim is available (as opposed to bad network, or mobile data disabled…)

@teolemon
Copy link
Member

After investigation, the bug appears limited in scope.
I can't reproduce on a SIM-less Pixel 1 on Android 10.
Newer devices with mobile data disabled don't have the problem either.

@teolemon
Copy link
Member

teolemon commented Sep 4, 2020

image
Reported by another user

@teolemon
Copy link
Member

teolemon commented Sep 4, 2020

Merci pour votre réponse.J'utilise ma tablette, je l'ai essayé avec wifi et 4G, mon réseau est n'était pas faible et je suis sur Android 7.

Translation:

Thank you for your reply, I am using my tablet, I tried it with wifi and 4G, my network was not weak and I am on Android 7.

@teolemon
Copy link
Member

teolemon commented Sep 4, 2020

@teolemon teolemon modified the milestones: v3.4.2, 4.0 Sep 5, 2020
@teolemon teolemon added Android 7 Android Nougat related issues and feature requests P1 labels Sep 5, 2020
@teolemon teolemon pinned this issue Sep 8, 2020
@teolemon
Copy link
Member

teolemon commented Sep 8, 2020

A change in network connectivity has occurred. A default connection has either been established or lost. The NetworkInfo for the affected network is sent as an extra; it should be consulted to see what kind of connectivity event occurred.
Apps targeting Android 7.0 (API level 24) and higher do not receive this broadcast if they declare the broadcast receiver in their manifest. Apps will still receive broadcasts if they register their BroadcastReceiver with Context.registerReceiver() and that context is still valid.

12:22
that’s the best idea i have found so far
12:22
https://developer.android.com/reference/android/net/ConnectivityManager#CONNECTIVITY_ACTION

@teolemon
Copy link
Member

teolemon commented Sep 8, 2020

Another report:

Bis vor kurzem hat die App gut funktioniert. Jetzt sagt sie immer ich wäre offline und ich bekomme keine Produkte mehr geladen.

Translation:

Until recently, the app worked fine. Now she always says I'm offline and I can't get any more products loaded.

@teolemon
Copy link
Member

09-10 16:42:12.402 21594 21638 D OkHttp  : <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: Handshake failed

@teolemon
Copy link
Member

09-10 16:42:12.296 21594 21638 D OkHttp  : --> GET https://ssl-api.openfoodfacts.org/api/v0/product/3270722500141.json?fields=origins%2Crecycling_instructions_to_discard%2Cother_information%2Clink%2Clast_modified_by%2Ccode%2Cquantity%2Cpackaging%2Cingredients_that_may_be_from_palm_oil_tags%2Cproduct_name_en%2Cimage_nutrition_url%2Cproduct_name_fr%2Cno_nutrition_data%2Cimage_small_url%2Cgeneric_name_en%2Ctraces%2Cvitamins_tags%2Cingredients_text_en%2Ccreator%2Cadditives_tags%2Cstates_tags%2Cwarning_fr%2Cnutrition_data_per%2Cmanufacturing_places%2Cingredients_analysis_tags%2Cpurchase_places%2Cingredients%2Crecycling_instructions_to_recycle%2Cother%2Cother_nutritional_substances_tags%2Cproduct_name%2Cingredients_text%2Cimage_nutrition_url_en%2Cwarning_en%2Cnutrition_grades_tags%2Cgeneric_name%2Ccustomer_service%2Cingredients_from_palm_oil_tags%2Crecycling_instructions_to_recycle_en%2Cimage_front_url_en%2Ccities_tags%2Cingredients_from_or_that_may_be_from_palm_oil_n%2Camino_acids_tags%2Ccustomer_service_fr%2Cnutriments%2Curl%2Cselected_images%2Ceditors_tags%2Callergens_hierarchy%2Cminerals_tags%2Cbrands_tags%2Clast_modified_t%2Crecycling_instructions_to_recycle_fr%2Cimage_front_url%2Clabels_hierarchy%2Ccountries%2Cemb_codes_tags%2Cimage_nutrition_url_fr%2Cconservation_conditions_en%2Clang%2Cimage_front_url_fr%2Cwarning%2Callergens_tags%2Cingredients_text_fr%2Cimage_ingredients_url_fr%2Ccustomer_service_en%2Crecycling_instructions_to_discard_en%2Cstores%2Callergens%2Clanguages_codes%2Cnova_groups%2Cimage_ingredients_url_en%2Cenvironment_impact_level_tags%2Cnutrient_levels%2Cbrands%2Cimage_url%2Crecycling_instructions_to_discard_fr%2Cother_information_fr%2Cgeneric_name_fr%2Ccreated_t%2Cenvironment_infocard%2Cconservation_conditions%2Cnutrition_grade_fr%2Cserving_size%2Ctraces_tags%2Cconservation_conditions_fr%2Cingredients_from_palm_oil_n%2Cother_information_en%2Ccountries_tags%2Cimage_ingredients_url%2Ccategories_tags%2Clabels_tags
09-10 16:42:12.300  2324  2787 D EnterpriseController: netId is 0
09-10 16:42:12.300  2324  2787 D Netd    : getNetworkForDns: using netid 502 for uid 10171
09-10 16:42:12.300  2324  2787 D DnsProxyListener: DNSDBG::dns addrinfo af 0
09-10 16:42:12.335 21594 21707 D h       : Found barcode in 58 ms
09-10 16:42:12.342  2311  2311 I ShotCommon: enablePreviewMsgBy : msg(In:0x2, Out:0x2)
09-10 16:42:12.342  2311  2311 I ShotCommon: enableMsgType : msg(In:0x10, Out:0xc1d)
09-10 16:42:12.361  2311 21729 I ShotCommon: disablePreviewMsgBy : msg(In:0x2, Out:0x0)
09-10 16:42:12.361  2311 21729 I ShotCommon: previewCallbackEnabled (0x0)
09-10 16:42:12.361  2311 21729 I ShotCommon: disableMsgType : msg(In:0x10, Out:0xc0d)
09-10 16:42:12.384  2311  3439 I ExynosCamera: [CAM_ID(0)][]-INFO(getParameters[1284])
09-10 16:42:12.384  2311  3439 I ExynosCamera1Parameters: [CAM_ID(0)][ParametersBack]-INFO(getParameters[243])
09-10 16:42:12.384  2311  3439 D ExynosCameraInterface: DEBUG:duration time(    0 msec):(HAL_camera_device_get_parameters)
09-10 16:42:12.384  2311  3439 D ExynosCameraInterface: DEBUG:duration time(    0 msec):(HAL_camera_device_put_parameters)
09-10 16:42:12.402 21594 21638 D OkHttp  : <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: Handshake failed

@teolemon
Copy link
Member

We reverted a Nougat-specific fix while refactoring:
** Bug fixing **

@teolemon
Copy link
Member

The fix might be as simple as adding back this:

        if (Build.VERSION.SDK_INT == 24) {
            ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
                    .tlsVersions(TlsVersion.TLS_1_2)
                    .cipherSuites(CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
                    .build();

            httpClient = new OkHttpClient.Builder()
                    .connectTimeout(5000, TimeUnit.MILLISECONDS)
                    .readTimeout(30000, TimeUnit.MILLISECONDS)
                    .writeTimeout(30000, TimeUnit.MILLISECONDS)
                    .connectionSpecs(Collections.singletonList(spec))
                    .build();
        } else {
            httpClient = new OkHttpClient.Builder()
                    .connectTimeout(5000, TimeUnit.MILLISECONDS)
                    .readTimeout(30000, TimeUnit.MILLISECONDS)
                    .writeTimeout(30000, TimeUnit.MILLISECONDS)
                    .build();
        }

@teolemon
Copy link
Member

#793

@teolemon
Copy link
Member

@teolemon
Copy link
Member

otherwise, we can fix it client side

@stephanegigandet
Copy link

Making SSL changes for all users of all clients on the server side to fix one bug for one client is not a good idea IHMO. For all we know (or all we will never know), that change might break things for other clients, now or 3 years from now. So it would be much better to fix the app.

@teolemon
Copy link
Member

A bug on 20K clients

@teolemon teolemon linked a pull request Sep 11, 2020 that will close this issue
VaiTon pushed a commit to VaiTon/openfoodfacts-androidapp that referenced this issue Sep 12, 2020
VaiTon pushed a commit to VaiTon/openfoodfacts-androidapp that referenced this issue Sep 12, 2020
VaiTon pushed a commit that referenced this issue Sep 15, 2020
@teolemon teolemon unpinned this issue Sep 27, 2020
@huzaifaiftikhar
Copy link
Member

Closed via #3544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android 7 Android Nougat related issues and feature requests bug Produces incorrect or unexpected result or behaviour. network P1 candidate P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants