http.get on a local IP that is not available (not assigned) fails but does not call callback
The callback should be called allways, even on all failures
in the example it should print
callback
The callback is not called
-- > http.get("http://192.1.1.254/",nil,function() print "callback" end)
-- > HTTP client: Disconnected with error: -11
-- HTTP client: Connection timeout
-- HTTP client: Connection timeout
-- http.get("http://192.1.1.254/",nil,function() print "callback" end)
NodeMCU custom build by frightanic.com
branch: master
commit: c8ac5cfb912ff206b03dd7c60ffbb2dafb83fe5e
SSL: true
modules: bit,file,gpio,http,i2c,net,node,ow,pwm,rtctime,sjson,sntp,tmr,uart,wifi,tls
build built on: 2017-06-17 17:53
powered by Lua 5.1.4 on SDK 2.1.0(116b762)
Standard ESP6288 E-12 Dev Board
I have same behavior with http.post()
Module author @vowstar
I'd argue the current behavior is correct. The callback parameter is specified/documented as
The callback function to be invoked when the response has been received; it is invoked with the arguments status_code, body and headers
In your case no connection can be established and thus no status code, no body and no headers.
yes but the doc also says
Each request method takes a callback which is invoked when the response has been received from the server. The first argument is the status code, which is either a regular HTTP status code, or -1 to denote a DNS, connection or out-of-memory failure, or a timeout (currently at 10 seconds).
Interesting, never noted that paragraph. It makes sense and we should ensure consistency in the docs.
It would also be useful (at least) to know when processing of an http call is finished, so I can issue the next call.
Yes, you are right. When timeout it need a callback with error code -1.
PR merged -> closing