graphQLHttpClient Connection failure on Android, works on Windows

graphQLHttpClient Connection failure on Android, works on Windows


0

I have a Maui app which works just fine when I run it with as a Windows Machine, but switching to Android I get a connection failure. Same dev machine, same back-end server. It is running on localhost port 5001.

According to the server logs, it is not even hitting the Endpoint to submit the query. Endpoint is the same. Just upgraded to .Net 8. Not sure if this was a problem on .Net 7 as I had only been working with the Windows machines. I have included the code where the failure happens.

private static async Task<(RootObject obj, string rtnMsg)> GetDocumentAsync(string iQuery)
{
    RootObject obj = null;
    string rtnMsg = "";
    var graphQLOptions = new GraphQLHttpClientOptions
    {
        EndPoint = new Uri($"{Url}/graphql", UriKind.Absolute)
    };

    var graphQLHttpClient = new GraphQLHttpClient(graphQLOptions, new NewtonsoftJsonSerializer());

    var documentRequest = new GraphQLRequest { Query = iQuery };

    try
    {
        var graphQLResponse = await graphQLHttpClient.SendQueryAsync<RootObject>(documentRequest);
        Debug.Print("");
        return (graphQLResponse.Data,"");
    }
    catch (Exception ex)
    {
        rtnMsg = ex.Message + " [ErpPart.GetDocumentAsync]";
        Debug.Print(ex.Message);
        return (obj,rtnMsg);
    }
}

1

  • Don’t use localhost. There are many, many existing questions that address this

    – Jason

    1 hour ago


Load 2 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *