# Catching "Timeout when connecting to server" error

**URL:** <https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223>\
**Category:** General\
**Created:** [6 August 2020 12:48 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223 "2020-08-06T12:48:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeh](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mikeh](https://discourse.nodered.org/u/mikeh)\
**Post date:** [6 August 2020 12:48 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/1 "2020-08-06T12:48:46Z")

</div>

How do I catch this error from FTP node? "Timeout when connecting to server"  
I'm using this node-red-contrib-advanced-ftp  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28717850cdd5bd03f6503697f139c23c7c4e4e8f.png)

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 13:41 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/2 "2020-08-06T13:41:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikeh](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mikeh](https://discourse.nodered.org/u/mikeh)\
**Post date:** [6 August 2020 23:21 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/3 "2020-08-06T23:21:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b5d0ac4b3b695b3ce87da158e7c83596050d07f.png)  
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?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 August 2020 01:03 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/4 "2020-08-07T01:03:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mikeh](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mikeh](https://discourse.nodered.org/u/mikeh)\
**Post date:** [7 August 2020 01:30 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/5 "2020-08-07T01:30:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [7 August 2020 05:07 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/6 "2020-08-07T05:07:39Z")

</div>

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.

Johannes

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

---

<div class="post-metadata">

**Author:** ![mikeh](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mikeh](https://discourse.nodered.org/u/mikeh)\
**Post date:** [7 August 2020 05:22 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/7 "2020-08-07T05:22:51Z")

</div>

> [@mikeh](#):
>
> node-red-contrib-advanced-ftp

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.

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [7 August 2020 05:26 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/8 "2020-08-07T05:26:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikeh](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mikeh](https://discourse.nodered.org/u/mikeh)\
**Post date:** [7 August 2020 05:47 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/9 "2020-08-07T05:47:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 August 2020 05:59 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/10 "2020-08-07T05:59:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 August 2020 06:17 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/11 "2020-08-07T06:17:47Z")

</div>

> [@JGKK](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [7 August 2020 06:23 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/12 "2020-08-07T06:23:55Z")

</div>

Yes you are right 👍🏻 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_

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 October 2020 06:23 UTC](https://discourse.nodered.org/t/catching-timeout-when-connecting-to-server-error/31223/13 "2020-10-06T06:23:58Z")

</div>

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