"No response object"

Hi there,
I wanted to post the prediction value from python to template node but it says "No response object". Whenever I am trying to post, the python code take time to run and thus its not getting the value in template node. I even tried to add delay in function node but not working. Please anyone can help.

Thank you!

The http in node emits a msg with 2 special properties .req& .res

The original msg with these 2 properties MUST travel through your flow all the way to the http response node.

This is so it know how to reply.

One of your nodes is NOT returning the original msg & you are losing .req and .res

Use debug nodes on every node (set to show full msg object) you will see where they get dropped.

My money is on the python shell node.

Another reason to convert you image inside node-red (like I showed you in the other thread)

This is what I am getting after adding debug node to every node.

Where do you last see .req & .res in the msg ?

After JSON node, value is not getting in template.

Re-read my first reply.

The error is because .req & .res are missing from the msg object when it reaches HTTP response node

The debug node coming out of the HTTP in node will definitely have these 2 properties, some other node with be dropping them. Inspect every debug node output - where is the last place you see .req & .res

No. Add a debug to EVERY node. You'll see them in HTTP in node then in one of the other nodes they will be missing. Where in your flow do you last see the 2 properties?

Ps: if you are starting the flow by using the python shell button, there will never be a .req or .res property. Http response MUST be fed a msg that comes originally from a HTTP in node.

1 Like

Yes, I am getting those two properties in http request node after post method of http (prediction).

Okay, so thats why I am not getting .req and .res after pythonshell. Is there any other way to get that?

Your earlier screenshot shows they are not present.

If you name your debug nodes this will be much clearer

You keep editing your replies & adding new info. Makes the thread hard to follow.

Yes, don't use python shell

I have named debug node here.

But, I have to use pythonshell to get the predicted value and post it. How can I do that? Is there any other way?

Yes. There is always another way.

  • Try an exec node to run your python
    Or
  • Do it all in node-red instead of using python
    Or
  • Report the issue to the author of python shell node & wait for a fix
    Or
  • Fork python shell and fix it yourself

So, If I tried in node-red then do I need to write my python code in template node by selecting python format?

Node-red is JavaScript.

If you write python it needs to be executed outside of the V8 engine.

So when I say do it all in node-red I mean ZERO python

A different solution could be to run your python separately and communicate via MQTT to trigger it and receive results.

No, I cant use then node-red coz my python code is for AI and thus I must have to code in python. As you said, I have to run python seperately and communicate via MQTT to trigger.

You could fork the wire and recombine with a join node, then move the payload from the python back to msg.payload. this will preserve the msg.res property.
here is an e example .

[{"id":"e558b242.7545d8","type":"http in","z":"b779de97.b1b46","name":"","url":"/testres","method":"get","upload":false,"swaggerDoc":"","x":120,"y":4020,"wires":[["3066adcc.171432","a7e16621.0a5e98"]]},{"id":"3066adcc.171432","type":"change","z":"b779de97.b1b46","name":"simulate python node","rules":[{"t":"delete","p":"res","pt":"msg"},{"t":"delete","p":"req","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"out","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"new payload","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":4100,"wires":[["e24596fe.21c638"]]},{"id":"a7e16621.0a5e98","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"in","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":4020,"wires":[["e24596fe.21c638"]]},{"id":"e24596fe.21c638","type":"join","z":"b779de97.b1b46","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":490,"y":4020,"wires":[["7b065495.841a3c"]]},{"id":"7b065495.841a3c","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"move","p":"payload.out","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":4020,"wires":[["2f2c1603.e05c4a"]]},{"id":"2f2c1603.e05c4a","type":"http response","z":"b779de97.b1b46","name":"","statusCode":"","headers":{},"x":850,"y":4020,"wires":[]},{"id":"16627390.3c7064","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":3900,"wires":[["285b8f7f.973a6"]]},{"id":"285b8f7f.973a6","type":"http request","z":"b779de97.b1b46","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.25:1880/testres","tls":"","persist":false,"proxy":"","authType":"","x":370,"y":3880,"wires":[["41fb5918.053a8"]]},{"id":"41fb5918.053a8","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":3900,"wires":[]}]
1 Like

where I can add pythonshell in this example?