Hello, I have been having trouble debugging my xamarin.forms code not able to receive a valid post response from an AWS server with Flask running
Here are the snippets in my xamarin app:
<---PhotoViewModel.cs---->
ExaminePhotoCommand = new Command(async () => await ExaminePhoto()); // binded to a button because of MVVM pattern
.
.
async Task ExaminePhoto()
{
if (photo == null) //path to photo
{
Console.Write("Has not taken a photo");
return;
}
Stream photoStream = await photo.OpenReadAsync();
await Doctor.GetInstance().Examine(photoStream); //calling Examine in DoctorModel
}
<--->
<--DoctorModel.cs--->
using Newtonsoft.Json;
using System.Net.Http;
public async Task Examine(Stream imageStream)
{
<--Image to Json Conversion->
try
{
HttpRequestMessage request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("http//:url"),
Content = new StringContent(jsonScan)
};
Console.WriteLine("Sending request");
HttpResponseMessage response = await client.SendAsync(request); // the response will always timeout after client's Timespan
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
catch (Exception e)
{
Console.WriteLine("Examine timeout");
}
}
<----->
I am a beginner in xamarin forms and c# concurrency concepts.
The server gives 200 status every time the request is sent but a response is never received for some reason.
I am not sure if this is caused by my code or some setting in the server.