Strange behavior with http requests to Open-Meteo API and a temporary work-around

Hello, I just started building things with Node-RED and have completed a few small projects already. But today I ran into a strange issue trying to use Open-Meteo weather API.

I was not able to get a plain text/json response from the API no matter what I tried. The http request would just seem to hang. I just got it working with Return set to UTF8 String, which of course I could not decode because it seemed compressed data. (Binary buffer Return would hang too.)

Anyway, I tried the configuration from a post on this forum (thank you @kitori) ... and that would not work either.

However, after wiring in an additional, parallel, http request block, without any delay, AND with Accept-Encoding set to gzip AND Return set to UTF-8, AND a debug connected to the added http request AND printing of msg.payload enabled, THEN and ONLY THEN would both requests succeed, and I could obtain a plain-text JSON response.

So I have a work-around that is usable, but tricky, and it remains a mystery why this works only under that very tight set of conditions. For one http request, I need this:

[{"id":"af8a69a642424a54","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":640,"wires":[["f4a61e30fd8ae331"]]},{"id":"48931710a0e3a2b7","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":640,"wires":[]},{"id":"91416596b177742c","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":640,"wires":[["48931710a0e3a2b7"]]},{"id":"f4a61e30fd8ae331","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":640,"wires":[["91416596b177742c","49c605c4471c46c6"]]},{"id":"49c605c4471c46c6","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Accept-Encoding","valueType":"other","valueValue":"gzip"}],"x":750,"y":700,"wires":[["da284bd33b670601"]]},{"id":"68c7673223a28b90","type":"comment","z":"cfe1a0d0dae1525b","name":"Works when debug has node status message checked","info":"","x":1260,"y":660,"wires":[]},{"id":"da284bd33b670601","type":"debug","z":"cfe1a0d0dae1525b","name":"debug 1","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":940,"y":700,"wires":[]}]

This is flow with all the variations I tried and most not working.

[{"id":"f5b50c603be5f115","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":80,"wires":[["29d8e0ce4a501b4d"]]},{"id":"32a940b02d2c8a4b","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":80,"wires":[]},{"id":"b4da9239f124e79d","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":80,"wires":[["32a940b02d2c8a4b"]]},{"id":"29d8e0ce4a501b4d","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":80,"wires":[["b4da9239f124e79d"]]},{"id":"3229f6f24f7569bf","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":160,"wires":[["93be1ee42320f0e7"]]},{"id":"d38981152f0bab2d","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":160,"wires":[]},{"id":"53fa3139242c9037","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":160,"wires":[["d38981152f0bab2d"]]},{"id":"93be1ee42320f0e7","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[["53fa3139242c9037","431832bf4c134e48"]]},{"id":"ee89c8f72e7bf39b","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":220,"wires":[]},{"id":"431832bf4c134e48","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":220,"wires":[["ee89c8f72e7bf39b"]]},{"id":"b10a25cfbfabe4c0","type":"comment","z":"cfe1a0d0dae1525b","name":"Original Hangs! (200 return code shows though)","info":"","x":1240,"y":80,"wires":[]},{"id":"4c7484b128ccc0c8","type":"comment","z":"cfe1a0d0dae1525b","name":"Hangs too in the same way","info":"","x":1170,"y":180,"wires":[]},{"id":"6205e836136cde5d","type":"comment","z":"cfe1a0d0dae1525b","name":"Works but only if one http request requests UTF8 string AND has Accept-Encoding: gzip","info":"","x":1360,"y":420,"wires":[]},{"id":"2dae0bff1a9b2180","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":280,"wires":[["c24fc6a5cfa2e1e5"]]},{"id":"25ef30fe3d48ab0e","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":280,"wires":[]},{"id":"aa35e041d067b7db","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":280,"wires":[["25ef30fe3d48ab0e"]]},{"id":"c24fc6a5cfa2e1e5","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":280,"wires":[["aa35e041d067b7db","f77fadc1d33e10f1"]]},{"id":"679b3a207232f233","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":340,"wires":[]},{"id":"f77fadc1d33e10f1","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":340,"wires":[["679b3a207232f233"]]},{"id":"3a748d52e2e232f5","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":400,"wires":[["429e2b9b63472057"]]},{"id":"782ee000ced64ec9","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":400,"wires":[]},{"id":"1a93aa3d684d6407","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":400,"wires":[["782ee000ced64ec9"]]},{"id":"429e2b9b63472057","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":400,"wires":[["1a93aa3d684d6407","2411a7e5db8a993d"]]},{"id":"9ab97da9ef2e6182","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":460,"wires":[]},{"id":"2411a7e5db8a993d","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Accept-Encoding","valueType":"other","valueValue":"gzip"}],"x":750,"y":460,"wires":[["9ab97da9ef2e6182"]]},{"id":"fc3eac98daae8f97","type":"comment","z":"cfe1a0d0dae1525b","name":"Hangs too in the same way","info":"","x":1170,"y":300,"wires":[]},{"id":"c8616bcea7f7b813","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":520,"wires":[["fa80c1977c403d9c"]]},{"id":"b72ec157d6dc303f","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":520,"wires":[]},{"id":"d0c7cd9a3a8fdd7a","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":520,"wires":[["b72ec157d6dc303f"]]},{"id":"fa80c1977c403d9c","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":520,"wires":[["d0c7cd9a3a8fdd7a","7ba12a953f59e2ec"]]},{"id":"e9218181165c8006","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":580,"wires":[]},{"id":"7ba12a953f59e2ec","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Accept-Encoding","valueType":"other","valueValue":"gzip"}],"x":750,"y":580,"wires":[["e9218181165c8006"]]},{"id":"d1ffd5027d79ef0c","type":"comment","z":"cfe1a0d0dae1525b","name":"Hangs when debug on the UTF8 one is disabled (or disconnected)!?","info":"","x":1300,"y":540,"wires":[]},{"id":"5d54bb029861ae57","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":760,"wires":[["ea55de05cd950c69"]]},{"id":"9513d866db7c80a7","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":760,"wires":[]},{"id":"982057471468f147","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":760,"wires":[["9513d866db7c80a7"]]},{"id":"ea55de05cd950c69","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":760,"wires":[["982057471468f147","3a75984f0ed2439f"]]},{"id":"9ac148b0fc95d933","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":820,"wires":[]},{"id":"82f401c615e270d2","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Accept-Encoding","valueType":"other","valueValue":"gzip"}],"x":750,"y":820,"wires":[["9ac148b0fc95d933"]]},{"id":"3a75984f0ed2439f","type":"delay","z":"cfe1a0d0dae1525b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":820,"wires":[["82f401c615e270d2"]]},{"id":"11c7b95072323d94","type":"comment","z":"cfe1a0d0dae1525b","name":"Hangs when other request is delayed","info":"","x":1210,"y":760,"wires":[]},{"id":"af8a69a642424a54","type":"inject","z":"cfe1a0d0dae1525b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":640,"wires":[["f4a61e30fd8ae331"]]},{"id":"48931710a0e3a2b7","type":"debug","z":"cfe1a0d0dae1525b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"statusCode","statusType":"msg","x":930,"y":640,"wires":[]},{"id":"91416596b177742c","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":640,"wires":[["48931710a0e3a2b7"]]},{"id":"f4a61e30fd8ae331","type":"change","z":"cfe1a0d0dae1525b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.latitude","pt":"msg","to":"52.5244","tot":"num"},{"t":"set","p":"payload.longitude","pt":"msg","to":"13.4105","tot":"num"},{"t":"set","p":"payload.current","pt":"msg","to":"temperature_2m,relative_humidity_2m,rain,weather_code,cloud_cover","tot":"str"},{"t":"set","p":"payload.hourly","pt":"msg","to":"temperature_2m","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":640,"wires":[["91416596b177742c","49c605c4471c46c6"]]},{"id":"49c605c4471c46c6","type":"http request","z":"cfe1a0d0dae1525b","name":"Open-Meteo.com","method":"GET","ret":"txt","paytoqs":"query","url":"https://api.open-meteo.com/v1/forecast","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Accept-Encoding","valueType":"other","valueValue":"gzip"}],"x":750,"y":700,"wires":[["da284bd33b670601"]]},{"id":"68c7673223a28b90","type":"comment","z":"cfe1a0d0dae1525b","name":"Works when debug has node status message checked","info":"","x":1260,"y":660,"wires":[]},{"id":"da284bd33b670601","type":"debug","z":"cfe1a0d0dae1525b","name":"debug 1","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":940,"y":700,"wires":[]},{"id":"7dd93813772eb45c","type":"comment","z":"cfe1a0d0dae1525b","name":"Tested with Node-RED v4.0.2","info":"","x":640,"y":40,"wires":[]}]

I am running Node-RED v4.0.2 in a container (apptainer) bootstrapped from docker image nodered/node-red:latest-22, actually 22.7.0, on Debian.

Is this a bug?

yes, the Open-Meteo site is not very responsive and often the requests fail... you just have to repeat the attempt .. just check for msg.statusCode ..which will have any error code.

I have setup for 2 request attempts .. you can do for 3 or more if you prefer

That looks very painful. Maybe easier to pull the whole dataset from S3 and running your own API.

But I have not seen that kind of behavior (with very simple requests though). In my case, the requests either hangs indefinitely (even with timeouts set) or completes immediately every single time (using the work-around I posted).

I suspect there is some bug in node-RED, but I am too new to this to jump into building and running some kind of debugger.