0

This question is specific to a lately strange behavior of the Azure mobile Apps Android sdk. Everything was working fine for weeks. Now, my android client app suddenly can't connect to my web app any more. A Toast says "Error while processing request". In Android Studio debugger, I found the exception inside the SDK file MobileServiceConnection.java.

java.io.IOException: stream was reset: PROTOCOL_ERROR 

In Azure Portal, my app shows "Healthy" status, but I can see the HTTP errors. Please help. Following is my code, which was working fine and now throws error.

// Create the Mobile Service Client instance, using the provided mobile app URL. try { mClient = new MobileServiceClient(mMobileBackendUrl, activityContext).withFilter( new ServiceFilter() { @Override public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request, NextServiceFilterCallback nextServiceFilter) { // Get the request contents String url = request.getUrl(); String content = request.getContent(); if (url != null) { Log.d("Request URL:", url); } if (content != null) { Log.d("Request Content:", content); } // Execute the next service filter in the chain ListenableFuture<ServiceFilterResponse> responseFuture = nextServiceFilter.onNext(request); Futures.addCallback(responseFuture, new FutureCallback<ServiceFilterResponse>() { @Override public void onFailure(Throwable exception) { Log.d("Exception:", exception.getMessage()); } @Override public void onSuccess(ServiceFilterResponse response) { if (response != null && response.getContent() != null) { Log.d("Response Content:", response.getContent()); } } }); return responseFuture; } } ); setAzureClient(mClient); }catch(MalformedURLException e){ createAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error"); }catch(Exception e){ createAndShowDialog("There was an error creating the Mobile Service. "+ e.toString(), "Error"); } Toast.makeText(context, context.getString(R.string.online_authentication), Toast.LENGTH_SHORT).show(); authenticate(); } private void authenticate() { // give access only to authenticated users via Google account authentication HashMap<String, String> parameters = new HashMap<>(); parameters.put("access_type", "offline");//use "Refresh tokens" //login with the Google provider. This will create a call to onActivityResult() method inside the context Activity, which will then call the onActivityResult() below. mClient.login(MobileServiceAuthenticationProvider.Google, url_scheme_of_your_app, GOOGLE_LOGIN_REQUEST_CODE, parameters); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // When request completes if (requestCode == 1) { try { MobileServiceActivityResult result = mClient.onActivityResult(data); if (result.isLoggedIn()) { Toast.makeText(context, context.getString(R.string.azure_auth_login_success) /*+ " " + mClient.getCurrentUser().getUserId()*/, Toast.LENGTH_SHORT).show(); mUserId = mClient.getCurrentUser().getUserId(); } else {//>>>>THIS IS WHERE I AM GETTING THE ERROR String errorMessage = result.getErrorMessage(); Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT).show();// Error While processing request (it comes form the MobileServiceConnection.java file inside sdk) } }catch(Exception e){ Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); } } } 
5
  • I would suggest you change “HttpClientHandler” to “AndroidClientHandler” in the Android option (tab Advanced) of your Android project and see if it helps. Also, restart your application and try it again. Could you share the HTTP error code which you are getting? Also, you may check this GitHub link: github.com/Azure/azure-mobile-apps/wiki/…! Commented Apr 5, 2018 at 3:40
  • @SwikrutiBose thanks for the reply. Where I can find this option? I am using Android Studio and the Azure Portal. Commented Apr 5, 2018 at 5:30
  • @SwikrutiBose updated my question, added the filter. The executios never reaches Futures.addCallback because it throws exception from inside the sdk (file MobileServiceConnection.java) Commented Apr 5, 2018 at 5:57
  • @SwikrutiBose I am not sure how to get the HHTP error code. Azure portal shows a diagram with http errors on a timeline Commented Apr 5, 2018 at 6:17
  • @SwikrutiBose I can see the following line in Azure Portal: Application Errors App Service Authentication specific error detected (500.73) - An internal error occurred during the login process. For example, required protocol data or tokens were missing. Commented Apr 5, 2018 at 6:39

1 Answer 1

2

I found the answer myself. The error was due to an Azure App Service HTTP2 connection issue. It has nothing to do with the app code. For anyone facing the same problem, here is the solution.

  1. Go to https://resources.azure.com/
  2. Make sure you are in Read/Write mode by clicking in the option to the left of your name.
  3. From the left column, browse to: https://resources.azure.com/subscriptions/yourSubscriptionId/resourceGroups/yourWebAppResourceGroup/providers/Microsoft.Web/sites/yourWebAppName/config/web
  4. Find and Change the property: "http20Enabled": from true to false by clicking EDIT, Update value to “false” and then clicking in Save or PATCH.
Sign up to request clarification or add additional context in comments.

2 Comments

As you have got it resolved, it would be better if you could mark it as an answer, which might help other customers with the similar issue.
took me two days to find your post. I was doomed otherwise :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.