How to catch 1 error many times

Hi,

I send the file using ftp (node-red-contrib-ftp) node, in case the sending fails, I want to resend with the specified number of times.
If the specified number of times fails to send the file, the error message will be displayed.

I have tried to execute with the flow as below, the error "Message exceeded maximum number of catches" has occurred, indicates that the catch node has an internal fail-safe to prevent endless loops.

[{"id":"253f62e9.8c881e","type":"tab","label":"Catch FTP","disabled":false,"info":""},{"id":"958f10a1.7f7","type":"inject","z":"253f62e9.8c881e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":290,"y":180,"wires":[["faeb86e6.459f98"]]},{"id":"faeb86e6.459f98","type":"change","z":"253f62e9.8c881e","name":"","rules":[{"t":"set","p":"count","pt":"global","to":"15","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":180,"wires":[["102beac8.b0b405"]]},{"id":"b327d5f9.4a55f8","type":"catch","z":"253f62e9.8c881e","name":"catch [ftp] node","scope":["36599409.788abc"],"uncaught":false,"x":300,"y":360,"wires":[["46bbcb02.5fae34"]]},{"id":"36599409.788abc","type":"ftp in","z":"253f62e9.8c881e","ftp":"5c57a739.a7bd48","operation":"put","filename":"Test.ini","localFilename":"C:\\Temp\\Test.ini","name":"","x":890,"y":180,"wires":[[]]},{"id":"102beac8.b0b405","type":"change","z":"253f62e9.8c881e","name":"i = 0","rules":[{"t":"set","p":"i","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":180,"wires":[["36599409.788abc"]]},{"id":"46bbcb02.5fae34","type":"switch","z":"253f62e9.8c881e","name":"msg.i = global.count ?","property":"i","propertyType":"msg","rules":[{"t":"eq","v":"count","vt":"global"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":360,"wires":[["6d3c581.f0c04a8"],["6d420ea5.2cb2c"]]},{"id":"6d420ea5.2cb2c","type":"change","z":"253f62e9.8c881e","name":"i++","rules":[{"t":"set","p":"i","pt":"msg","to":"$.i + 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":300,"wires":[["36599409.788abc","c349acc5.5986d"]]},{"id":"13e0fbb5.197cc4","type":"debug","z":"253f62e9.8c881e","name":"Failed to send file!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":420,"wires":[]},{"id":"6d3c581.f0c04a8","type":"change","z":"253f62e9.8c881e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Failed to send file!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":420,"wires":[["13e0fbb5.197cc4"]]},{"id":"c349acc5.5986d","type":"debug","z":"253f62e9.8c881e","name":"i","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"i","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":300,"wires":[]},{"id":"5c57a739.a7bd48","type":"ftp","z":"","host":"localhost","port":"21","secureOptions":"","user":"admin","connTimeout":"","pasvTimeout":"","keepalive":""}]

catch-ftp-specific-times

In this case, what should I do?
Any hint will be great.
Thanks!

somthing like this , untested as no ftp node on my machine.

[{"id":"faeb86e6.459f98","type":"change","z":"8d8a515a.78af18","name":"count ++ and ftp vals","rules":[{"t":"set","p":"count","pt":"msg","to":"error.source.count + 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1500,"wires":[["46bbcb02.5fae34"]]},{"id":"46bbcb02.5fae34","type":"switch","z":"8d8a515a.78af18","name":"count greater than 6","property":"count","propertyType":"msg","rules":[{"t":"lt","v":"7","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":390,"y":1380,"wires":[["7197c896.b788c8"],["6d3c581.f0c04a8"]]},{"id":"b327d5f9.4a55f8","type":"catch","z":"8d8a515a.78af18","name":"catch [ftp] node","scope":["7197c896.b788c8"],"uncaught":false,"x":170,"y":1500,"wires":[["faeb86e6.459f98"]]},{"id":"6d3c581.f0c04a8","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Failed to send file!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":1420,"wires":[["13e0fbb5.197cc4"]]},{"id":"7197c896.b788c8","type":"http request","z":"8d8a515a.78af18","name":"ftp simulate","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://www.hfhfhhhdjk.com","tls":"","persist":false,"proxy":"","authType":"","x":760,"y":1360,"wires":[[]]},{"id":"958f10a1.7f7","type":"inject","z":"8d8a515a.78af18","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"count","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ftp values etc","payloadType":"str","x":160,"y":1380,"wires":[["46bbcb02.5fae34"]]},{"id":"13e0fbb5.197cc4","type":"debug","z":"8d8a515a.78af18","name":"Failed to send file!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":1420,"wires":[]}]

[edit ] no need for context storage.

1 Like

@E1cid Thank you for your effort!
Based on your code, I replaced count greater than 6 with count greater than 20,
the error as described above still appears...

I wonder if it is possible to change the value of maximum number of catches !?
I'm trying to search this way...

No just delete error property count, msg.error.source.count each loop

[{"id":"958f10a1.7f7","type":"inject","z":"8d8a515a.78af18","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"count","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ftp values etc","payloadType":"str","x":160,"y":1380,"wires":[["46bbcb02.5fae34"]]},{"id":"46bbcb02.5fae34","type":"switch","z":"8d8a515a.78af18","name":"count greater than 6","property":"count","propertyType":"msg","rules":[{"t":"lt","v":"20","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":390,"y":1380,"wires":[["7197c896.b788c8"],["6d3c581.f0c04a8"]]},{"id":"6d3c581.f0c04a8","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Failed to send file!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":1420,"wires":[["13e0fbb5.197cc4"]]},{"id":"d0c9a4de.c79f38","type":"delay","z":"8d8a515a.78af18","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":1440,"wires":[["46bbcb02.5fae34"]]},{"id":"7197c896.b788c8","type":"http request","z":"8d8a515a.78af18","name":"ftp simulate","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://www.hfhfhhhdjk.com","tls":"","persist":false,"proxy":"","authType":"","x":760,"y":1360,"wires":[[]]},{"id":"13e0fbb5.197cc4","type":"debug","z":"8d8a515a.78af18","name":"Failed to send file!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":1420,"wires":[]},{"id":"faeb86e6.459f98","type":"change","z":"8d8a515a.78af18","name":"clear error","rules":[{"t":"set","p":"error.source.count","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"count","pt":"msg","to":"count+ 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1500,"wires":[["d0c9a4de.c79f38"]]},{"id":"b327d5f9.4a55f8","type":"catch","z":"8d8a515a.78af18","name":"catch [ftp] node","scope":["7197c896.b788c8"],"uncaught":false,"x":170,"y":1500,"wires":[["faeb86e6.459f98","ea5b1d29.6d31f"]]},{"id":"ea5b1d29.6d31f","type":"debug","z":"8d8a515a.78af18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":240,"y":1620,"wires":[]}]
1 Like

@E1cid Thank you very much!
I also think like @E1cid and have done it.
I deleted msg.error right after the catch node.

catch-ftp

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.