Client calling HTTP POST getting timeout after RESPONSE



I have a simple node flow that takes an HTTP POST in, does some stuff and then returns its results in the HTTP RESPONSE. To investigate this problem I have short-circuited the 'does some stuff' step, so basically it takes the POST request and sends a corresponding RESPONSE.

The problem: My client gets the HTTP RESPONSE fine, but also appears to get a timeout message?!? One of my clients is set to retry 9 times in the event of a failure and therefore gets the same response 9 times. Each POST through my node flow has a different message ID.

I am relatively new to NodeRed so I may be doing something obviously wrong, but given the simplicity of the flow I am struggling to see what.

Any help much appreciated



When your flow gets to the http response node at the end, it must include the original msg.req and msg.res properties that were created by the http in node... sounds like that is not happening.

If you want to post your flow, select just those nodes from the input node through the flow to the response node. Then in the upper right menu, choose Export -> Clipboard -> Selected Nodes and copy the resulting JSON text. Paste it into this thread between two lines that contain only 3 back-tics so it is easy for us to grab and import. My guess is that the "does some stuff" steps are rebuilding the msg object, or overwriting the req/res fields.



Shrickus, thanks for the reply, here are my nodes:

[{"id":"5de1f658.fbd058","type":"http in","z":"f96fb187.6c7a2","name":"My In","url":"/queryIn","method":"post","upload":false,"swaggerDoc":"","x":410,"y":1240,"wires":[["282cc3c3.15fe0c"]]},{"id":"282cc3c3.15fe0c","type":"function","z":"f96fb187.6c7a2","name":"","func":"msg.chatId = msg.payload._msgid;\nmsg.payload = msg.payload.input;\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":610,"y":1240,"wires":[["a1fe80b8.4d36a"]]},{"id":"a1fe80b8.4d36a","type":"function","z":"f96fb187.6c7a2","name":"hello world","func":"\n\nmsg.payload = {\n  chatId : msg.chatId,\n  answers: \"hello world\",\n  }\n\n  \n  return msg;","outputs":1,"noerr":0,"x":870,"y":1240,"wires":[["1a8c1344.c8f8fd"]]},{"id":"1a8c1344.c8f8fd","type":"http response","z":"f96fb187.6c7a2","name":"my response","statusCode":"","headers":{},"x":1150,"y":1240,"wires":[]}]




Use debug nodes to determine what is happening within your flow. Initially disable retry in the client to make it easier to see what is happening.



Since you are trying to return the payload as JSON, I believe you just need to set the response headers with the correct content-type:


Otherwise, the content-length will not match the data, and the client may be expecting more, so it doesn't close the connection.



Thanks for the reply Colin. Unfortunately the client that is making the call is a 3rd party service so changing the retry is out of my control. I have debug points in and from eyeballing the msg.req/msg/res objects they appear to be passing out as they were passed in. All very strange



the content-length seems like a logical solution and the sort of 'silly' thing that would be catching me out but sadly I have added the headers but to no avail, I still get the repeated attempts caused by the timeout

Thanks for the suggestion though