Hi There!
I just discovered something about the http request node and I'm wondering whether that might change with NR 3.1.x
The requestTimeout
value is in fact the connect timeout, i.e. the limit on connecting to the server, it is not the time limit for the server to respond. This means that a server can open the connection within the requestTimeout
time but then not respond for X seconds. The http request node would hold the connection for those X seconds and longer.
This flow is a demonstration of that - requestTimeout
is 1 second while the endpoint delays 5 seconds before sending reponse:
[{"id":"4de89aba64f6a744","type":"inject","z":"e46be6066ea2231c","name":"set url and count","props":[{"p":"payload"},{"p":"url","v":"http://localhost:1880/end/point","vt":"str"},{"p":"count","v":"30","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":428,"y":365,"wires":[["c5071dcbcf7ced38"]]},{"id":"c5071dcbcf7ced38","type":"function","z":"e46be6066ea2231c","name":"create count number of messages \\n with requestTimeout","func":"msg.payload = [];\n\nfor ( var idx = 0 ; idx < msg.count; idx++ ) {\n msg.payload.push({\n url: msg.url,\n requestTimeout: 1000,\n })\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":270,"wires":[["bfb961534391079d"]]},{"id":"bfb961534391079d","type":"split","z":"e46be6066ea2231c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":948,"y":340,"wires":[["b17afc78fb472d40"]]},{"id":"b17afc78fb472d40","type":"http request","z":"e46be6066ea2231c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1116,"y":395,"wires":[["5f78cbafd3481358"]]},{"id":"e6be7a5009f301b6","type":"catch","z":"e46be6066ea2231c","name":"","scope":["b17afc78fb472d40"],"uncaught":false,"x":1143,"y":365,"wires":[[]]},{"id":"5f78cbafd3481358","type":"join","z":"e46be6066ea2231c","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1301,"y":444,"wires":[["ebfe60187962ec1d"]]},{"id":"68b5f5cc96af4dfc","type":"http in","z":"e46be6066ea2231c","name":"","url":"/end/point","method":"get","upload":false,"swaggerDoc":"","x":564,"y":516,"wires":[["b3176bfe3e920a9a"]]},{"id":"d4f4d119f907475a","type":"http response","z":"e46be6066ea2231c","name":"","statusCode":"","headers":{},"x":980,"y":542,"wires":[]},{"id":"ebfe60187962ec1d","type":"function","z":"e46be6066ea2231c","name":"group by statusCode","func":"var newpload = {};\n\nfor ( var idx = 0; idx < msg.payload.length; idx++ ) {\n (newpload[msg.payload[idx].statusCode] ||= []).push(msg.payload[idx])\n}\n\nmsg.payload = newpload;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1530,"y":444,"wires":[["cfd421c114b151c1"]]},{"id":"cfd421c114b151c1","type":"debug","z":"e46be6066ea2231c","name":"debug 43","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1774,"y":389,"wires":[]},{"id":"b3176bfe3e920a9a","type":"delay","z":"e46be6066ea2231c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1700","randomLast":"2000","randomUnits":"milliseconds","drop":false,"allowrate":false,"outputs":1,"x":784,"y":582,"wires":[["d4f4d119f907475a"]]}]
I had a look at the code and it seems that the timeout
opt is set for the got
request. In newer versions of the got module timeout is a hash allowing for fine-grained timeout specifications, i.e., connect v. response timeout which would prevent this behaviour from the client side.
I was wondering whether new version of NR would support that?