Catching "Timeout when connecting to server" error

How do I catch this error from FTP node? "Timeout when connecting to server"
I'm using this node-red-contrib-advanced-ftp

How will I know if it an error like this occurred or not and do a retry?

Attach a Status node and you can monitor the status, also try a Catch node, which should only tell you when there is an error, but I haven't used the ftp node so I don't know exactly what it does. If you connect debug nodes to the catch and status nodes then you will be able to see what information they provide.

There's a Connection Timeout parameter when configuring the FTP server. I don't know what this blurred 10000 value is if that's seconds or ms. I would guess it's ms, but is it the default since it's blurred?

It's an example (placeholder) value of 10000ms. You can enter what ever ms value you want.

Internally, it likely is 10000 also but not necessarily.

Did the catch node catch your error?

I manually placed 60000 for a 60sec connection timeout. I already placed a catch node with an output to a log file. We'll have to wait and see for the error to happen though.

Just keep in mind that the catch node will only catch the error if the node uses the 1.0 api to send it via the provided done() function and or handles the node.error() correctly (which some nodes dont do). So using the status node as @Steve-Mcl suggested might be another thing to try should catch not work. Just use a switch node looking at msg.status.text after the status node.


Catch should work. Just looked at the nodes code on github and it has been updated by the author to be 1.0 compatible.

So same with your suggested on the switch node? I just need to get the exact text it's going to get from the catch node.

If you want the text under the node go with the status node as @Steve-Mcl said. Set to watch the ftp node it will send a msg every time the text under the node changes and will have that exact text in the msg.status.text property of the message.

I see.. So I could just do a status node and then check if the msg.status.text = "Timeout while connecting to server" on a switch node and just do a retry loop on that FTP node if it's true?

Better to use the catch node as that is what it is for. Set the timeout to a low value while you test your flow so you will get the error more often.

Umm... Not sure that is 100% correct advice mind Johannes?

So long as the error is called with an msg property node.error(err,msg), the catch node will catch.

1 Like

Yes you are right :+1:t2: just ran into a few nodes that didn’t do that and the catch node didn’t work than.
But the node in question looks good code wise on the error handling on quick glance.

Edited the concerned post above for future clarity