I'm accessing openweathermap to get the current temperature. It works well the first time, and sometimes the second, but then fails with "Connection Error" in the returned string. Where is that coming from? AnnexRDS or Open weather? The response is 466 bytes and handled easily, accessed via json. But the esp32 seems to lose connection. The code below is an extract from a bigger program for testing purposes, and below that is the log. Once it is reliable I will of course probably only access it once an hour, but for testing I'm trying for once every 20 seconds, which should not offend the server.
Any ideas to assist progress gratefully received.
Also, the ram seems to shrink somewhat.
wlog "start"
onwgetasync get_ext_temp
timer0 20000, check_time
wait
get_ext_temp:
a$=wgetresult$
wlog "response"+a$
W_ext_temp=val(JSON$(a$,"main.temp"))
wlog "-"+str$(W_ext_temp)+"-"
wlog ramfree
return
check_time:
wlog "requested api "+time$
wgetasync("
api.openweathermap.org/data/2.5/weather?id=7294598&units=metric&appid=63002d3f9removed7ba749845f5",443,1)
return
======================= responses received ================
start
requested api 21:41:58
responseHTTP/1.1 200 OK
Server: openresty
Date: Thu, 04 Feb 2021 21:42:00 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 466
Connection: close
X-Cache-Key: /data/2.5/weather?id=7294598&units=metric
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
{"coord":{"lon":-2.856,"lat":53.1899},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":6.56,"feels_like":2.66,"temp_min":6.11,"temp_max":7,"pressure":1005,"humidity":93},"visibility":8000,"wind":{"speed":4.12,"deg":90},"clouds":{"all":90},"dt":1612474718,"sys":{"type":1,"id":1399,"country":"GB","sunrise":1612425014,"sunset":1612458028},"timezone":0,"id":7294598,"name":"Great Boughton","cod":200}
-6.56-
127076
requested api 21:42:18
responseHTTP/1.1 200 OK
Server: openresty
Date: Thu, 04 Feb 2021 21:42:20 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 466
Connection: close
X-Cache-Key: /data/2.5/weather?id=7294598&units=metric
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
{"coord":{"lon":-2.856,"lat":53.1899},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":6.56,"feels_like":2.66,"temp_min":6.11,"temp_max":7,"pressure":1005,"humidity":93},"visibility":8000,"wind":{"speed":4.12,"deg":90},"clouds":{"all":90},"dt":1612474718,"sys":{"type":1,"id":1399,"country":"GB","sunrise":1612425014,"sunset":1612458028},"timezone":0,"id":7294598,"name":"Great Boughton","cod":200}
-6.56-
79816
requested api 21:42:38
responseConnection Error