Тема: Time Out Error on API Calls from .Net
Hello all.
We have developed a web API (Midleware) to monitor and calculate some wialon data in the moment (Temperature Sensor)
basically we get those values for each unit.
{
"Name": "53170R",
"UnitId": "15701017",
"Imei": "4662317653",
"Location": "Nw 138Th St, Miami, FL 33178, USA",
"Temperature": "93.3125",
"LastUpdate": "8/22/2018 9:58:53 PM",
"Log": "00:00:01.2497030"
},
but the issue is frequently we got an error: 504 Gateway Time-out
let say per 5 times we call methods got 3 fails with the 504 error.
What am doing is the following:
First we retrieve all units:
"svc", "core/search_items" with parameters:
"{\"spec\":{\"itemsType\":\"avl_unit\",\"propName\":\"sys_name\",\"propValueMask\":\"*\",\"sortType\":\"sys_name\"},\"force\":1,\"flags\": 4611686018427387903,\"from\":0,\"to\":0}"
And then for each unit we get more detail:
We get the location:
WialonGeoRefUrl = @"https://geocode-maps.wialon.com/hst-api.wialon.com/gis_geocode";
var coord = "[{\"lon\":" + lon.ToString() + ",\"lat\":" + lat.ToString() + "}]";
queriesStrings.Add("coords", coord);
queriesStrings.Add("flags", "1255211008");
queriesStrings.Add("uid", WialonId);
And last we get the value for temperature sensor:
"svc", "unit/calc_last_message" with parameters:
string command = "{\"unitId\":" + unitId + ",\"flags\":1,\"sensors\":[" + temperatureSensorId + "]}";
1 We retrieve all units In this case we have 180 units so we call:
2.For each unit we need to get location method and Calculate temperature sensor.
Approx.: 361 calls in less than 2 minutes.
We are calling the API from an ASP WEB API in C#
Hosted and tested in: AppHarbor and Microsoft Azure.
Do you has done something like this or know if is there better way to do it?
Thanks in advance.
Let me know if this help or if you need something else.