Hi,
fighting with memory and other tricks.
I have a strange error that come not at anytime. I guess it could be from the way i use the simu, App Settings Editor and OS but not sure of anything now.
in a watch face, background :
I am doing 3 makeWebrequest, 1st callback calling 2nd makeWebRequest, 2nd callback calling 3rd makeWebRequest.
1st is to get a Stock AMrket value, 2nd for weather and 3rd for 2nd stock market.
below is all println i made, from init to error :
****getInitialView =****
in userSettings : modification true
in userSettings Application.getApp().getProperty StockCode: GRMN
in userSettings StocksArray[0][2]: GRMN
in userSettings FULL StocksArray[0]: [true, 12, GRMN, null, 404, null, false, 5]
in userSettings changed: true - StocksArray[0][true, 12, GRMN, null, 404, null, false, 5]
in userSettings Application.getApp().getProperty StockCode1: MSFT
in userSettings StocksArray[1][2]: MSFT
in userSettings Changed : true - StocksArray[1][false, 13, MSFT, null, 404, null, false, 5]
in userSettings Changed : true - Updating Weather API Key to demo
****background init false intervalWebRequest ****5
****background register **** interval =>5
Background: ****makeRequestFirstStock **** RequestStocksArray 0= [true, 11, GRMN, null, 404, null, false, 3]
Background: in FIRST receivestock responseCode = -403 -- dataFirstStock = null
Background: in parseresponse receive StockResponse=> null
Background: in parseStockResponse exit with returnStocksArray [null, 400, false]
Background: ****makeRequestWeather ****
Background: ****receiveWeather **** responseCodeWeather = 401 -- data={message=>Invalid API key. Please see openweathermap.org/faq for more info., cod=>401}
Background: ****makeRequestNextStock **** RequestStocksArray 1= [false, 10, MSFT, null, 404, null, false, 5]
Background: in NEXT receivestock responseCode = 200 -- data = {Information=>The **demo** API key is for demo purposes only. Please claim your free API key at (www.alphavantage.co/.../ to explore our full API offerings. It takes fewer than 20 seconds, and we are committed to making it free forever.}
Background: in parseresponse receive StockResponse=> {Information=>The **demo** API key is for demo purposes only. Please claim your free API key at (www.alphavantage.co/.../ to explore our full API offerings. It takes fewer than 20 seconds, and we are committed to making it free forever.}
Background: in parseStockResponse exit with returnStocksArray [null, 408, false]
Back in onBackgroundData ----------- dataFromWebRequest = [[[null, 400, false], [null, 408, false]], [false, 401, KEY, A, RED, 1.100000, 90.000000, 24.500000]]
in userSettings : modification true
in userSettings Application.getApp().getProperty StockCode: GOOGL
in userSettings StocksArray[0][2]: GRMN
in userSettings FULL StocksArray[0]: [true, 11, GRMN, null, 400, null, false, 3]
in userSettings changed : modification
in userSettings changed: true - StocksArray[0][true, 11, GOOGL, null, 404, null, false, 5]
in userSettings Application.getApp().getProperty StockCode1: MSFT
in userSettings StocksArray[1][2]: MSFT
in userSettings Changed : true - StocksArray[1][true, 10, MSFT, null, 408, null, false, 6]
in userSettings Changed : true - Updating Weather API Key to xxxxxx
Background: ****makeRequestFirstStock **** RequestStocksArray 0= [true, 11, GOOGL, null, 404, null, false, 3]
Background: in FIRST receivestock responseCode = -403 -- dataFirstStock = null
Background: in parseresponse receive StockResponse=> null
Background: in parseStockResponse exit with returnStocksArray [null, 400, false]
Background: ****makeRequestWeather ****
Background: ****receiveWeather **** responseCodeWeather = -403 -- data=null
Background: ****makeRequestNextStock **** RequestStocksArray 1= [true, 10, MSFT, null, 408, null, false, 3]
Background: in NEXT receivestock responseCode = -403 -- data = null
Background: in parseresponse receive StockResponse=> null
Background: in parseStockResponse exit with returnStocksArray [null, 400, false]
Back in onBackgroundData ----------- dataFromWebRequest = [[[null, 400, false], [null, 400, false]], [false, -403, mem, A, RED, 1.100000, 90.000000, 24.500000]]
sometimes i will get the correct data in my call back, sometimes no.
Like for weather, where the error key return the correct error msg, and with a correct key return data is null.
I am absolutly sure it is not a return data memory error as it works.
for example, here are the data in HTTP Traffic in simu, for weather when i get the 403 error :
--------------------------- HTTP TRAFFIC LOGS ---------------------
GET /data/2.5/weather?units=metric&lon=6.83002&lat=43.4283&appid=xxxHTTP/1.1\r\nHost: api.openweathermap.org\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n
HTTP/1.1 200 OK\r\n
Server: openresty\r\n
Date: Tue, 03 Dec 2019 18:03:54 GMT\r\n
Content-Type: application/json; charset=utf-8\r\n
Content-Length: 444\r\n
Connection: keep-alive\r\n
X-Cache-Key: /data/2.5/weather?lat=43.43&lon=6.83&units=metric\r\n
Access-Control-Allow-Origin: *\r\n
Access-Control-Allow-Credentials: true\r\n
Access-Control-Allow-Methods: GET, POST\r\n
\r\n
{"coord":{"lon":6.83,"lat":43.43},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":10.11,"pressure":1019,"humidity":87,"temp_min":5.56,"temp_max":13.33},"visibility":10000,"wind":{"speed":1.5,"deg":360},"clouds":{"all":0},"dt":1575396174,"sys":{"type":1,"id":6507,"country":"FR","sunrise":1575355644,"sunset":1575388658},"timezone":3600,"id":2977246,"name":"Saint-Raphael","cod":200}
------------------------------
and for my Stock security with 403 error :
--------------------------- HTTP TRAFFIC LOGS ---------------------
GET /query?function=GLOBAL_QUOTE&symbol=MSFT&outputsize=compact&interval=60min&apikey=xxxxxxHTTP/1.1\r\nHost: www.alphavantage.co\r\nUser-Agent: Mozilla/5.0\r\nAccept: application/json\r\n\r\n
HTTP/1.1 200 OK\r\n
Connection: keep-alive\r\n
Server: gunicorn/19.7.0\r\n
Date: Tue, 03 Dec 2019 18:03:55 GMT\r\n
Transfer-Encoding: chunked\r\n
Content-Type: application/json\r\n
Allow: GET, HEAD, OPTIONS\r\n
Vary: Cookie\r\n
X-Frame-Options: SAMEORIGIN\r\n
Via: 1.1 vegur\r\n
\r\n
183\r\n{\n "Global Quote": {\n "01. symbol": "MSFT",\n "02. open": "147.4900",\n "03. high": "148.4100",\n "04. low": "146.6500",\n "05. price": "148.3179",\n "06. volume": "12740675",\n "07. latest trading day": "2019-12-03",\n "08. previous close": "149.5500",\n "09. change": "-1.2321",\n "10. change percent": "-0.8239%"\n }\n}\r\n
0\r\n\r\n
------------------------------
Memory usage is 62.3/92.0kb
Peak mem : 66.7kb
Object Mem : 93
Peak Objects : 135
What can it be from ?
i'm lost...
thanks.