Search code examples
timeouthttprequestnode-red

HttpRequest different timeouts per flow


i am trying to make two http requests with different timeouts per flow, i know i can configure globally httpRequestTimeout in the settings.js file but it sets the timeouts for all the flows.

I have two flows running in the same node-red and i need to set different timeouts for different http requests, i couldn't find a way to achieve it. I tried set the msg.req.timeout and msg.req.socket.server.timeout with no sucess.

Is there any way to acess the variables that are defined on settings.js? Mapping it to a env variable would be good as well.


Solution

  • Unfortunately this can only be set globally in settings.js and not over-ridden on a node by node basis.

    You can set variables in settings.js from environment variables since the file is effectively executed at startup so.

    ...
    httpRequestTimeout: process.env.HTTPREQUESTTIMEOUT,
    ...
    

    This would set the timeout to the value of the HTTPREQUESTTIMEOUT environment variable.