2

I'm trying to Register push notificationninmy Xamarin Android project. I get a Bad Gateway exception in the Register func of the GCMService class. Specifically a 502 error as follows.

"502 - Web server received an invalid response while acting as a gateway or proxy server.There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server" This my Register function

 public async void Register(Push push, IEnumerable<string> tags)
    {
        try
        {
            var templateBodyGCM = "{\"data\":{\"message\":\"$("+ RegistrationID+")\"}}";

            JObject templates = new JObject();
            templates["genericMessage"] = new JObject
            {
                {"body", templateBodyGCM}
            };

            await push.RegisterAsync(RegistrationID, templates);
            Log.Info("Push Installation Id", push.InstallationId.ToString());


            await Task.Run(async () => await RedCheetahApp.UpdateNotificationID(RegistrationID));
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
            Debugger.Break();
        }
    }

I call it in the MainActivity UI thread. I have a Azure Cloud service which my Android App calls to register and get and get push notification. I've tried calling the API via PostMan but I get the same error i.e Bad Request.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35
user2721794
  • 401
  • 1
  • 4
  • 20
  • Could you locate the specific code line in your `Register` function that throws the exception? Also, please provide the related core code in your Xamarin Android project and the related API to handle the registration in your Cloud service? – Bruce Chen Apr 28 '17 at 02:27
  • This is the line that throw the exception. await push.RegisterAsync(RegistrationID, templates); This is the API I see that is being called http://redcheetah.azurewebsites.net/push/installations/b60d0147-50a7-48b6-abea-cea21f204281 – user2721794 Apr 29 '17 at 07:31
  • @Bruce-MSFT Hi Bruce, still waiting on your reply. Thanks – user2721794 May 02 '17 at 08:21
  • I noticed that you are using azure web app. I assumed that you could refer to https://learn.microsoft.com/en-in/azure/app-service-web/app-service-web-troubleshoot-http-502-http-503 for troubleshooting this issue. – Bruce Chen May 02 '17 at 09:42

0 Answers0