"Connection Error" when using wget

85 views
Skip to first unread message

Stuart Gillies

unread,
Feb 4, 2021, 5:03:00 PM2/4/21
to Annex WiFi RDS
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.

Stuart

=========  test code  =============

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

Stuart Gillies

unread,
Feb 5, 2021, 12:52:25 PM2/5/21
to Annex WiFi RDS
I modified the code to display the time that an response was received. I now find that a third response is received, but the firmware hangs (red square) before the response can be displayed. I realise that I am using wlog several times but I'm using Ubuntu and don't know an easy way of seeing the output of 'print'. I'm guessing here that maybe it is something to do with the use of ram, which seems to be used but maybe not released each time?

ciccio cb

unread,
Feb 5, 2021, 1:11:04 PM2/5/21
to Annex WiFi RDS
HI Stuart,
there is probably a memory leak issue, in particular because you are using https: (443) that is very RAM memory consuming.
At first glance, try to use HTTP (port 80 instead of 443) as this should work.

I'm actually working on a new release that includes a completely new code for the WGET$ and WGETASYNC functions.
This new version will also improve the WLOG and all the HTML like functionalities.
I just checked and the code you sent works without any issue on the new version.
I'll release it in the next days.

--
You received this message because you are subscribed to the Google Groups "Annex WiFi RDS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to annex_wifi_rd...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/annex_wifi_rds/1c1a1fdc-576f-4688-b1d5-88128b0a5b6do%40googlegroups.com.

Stuart Gillies

unread,
Feb 5, 2021, 4:21:44 PM2/5/21
to Annex WiFi RDS
Great, thanks for all your efforts!

tuart

On Thursday, 4 February 2021 22:03:00 UTC, Stuart Gillies wrote:
Reply all
Reply to author
Forward
0 new messages