# No catch of TCP timeout

**URL:** https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735
**Category:** General
**Created:** [29 November 2020 23:39 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735 "2020-11-29T23:39:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![garybia](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@garybia](https://discourse.nodered.org/u/garybia)
#### Post date: [29 November 2020 23:39 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/1 "2020-11-29T23:39:34Z")

</div>

I am testing a disconnection of a tcp in node. I have an external computer connected to my node-red running on a pi. I set the the keep alive parameter on the pi set as

net.ipv4.tcp\_keepalive\_time = 60  
net.ipv4.tcp\_keepalive\_intvl = 60  
net.ipv4.tcp\_keepalive\_probes = 2

I pull the ethernet cable out of the external computer after it has started reporting after a couple of minutes I got the following message on the console that I started node-red on.

9 Nov 16:10:12 - [info] Started flows  
29 Nov 16:10:12 - [info] [tcp in:743745e5.05653c] listening on port 12000  
29 Nov 16:10:12 - [info] [mqtt-broker:Data Server broker] Connected to broker: mqtt://localhost:1883

29 Nov 16:13:03 - [info] [tcp in:743745e5.05653c] Error: read ETIMEDOUT

So node-red detected the error.

I have a catch node set up to catch errors on the [tcp in:743745e5.05653c] using the selected node option. From the catch node I have a debug node but the msg never showed up anything.

Interestingly if I put the status node looking at the same "tcp in" when the connection is made I get 1 connection showing and once the error occurs I get 0 connections.

Anyone got an idea why I would not have seen the the error in the debug node? Should it not catch this condition?

And can someone tell me where/how to look for known defects so I can check that list out.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [29 November 2020 23:52 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/2 "2020-11-29T23:52:49Z")

</div>

Are you looking at the complete msg with the debug node ?

---

<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: [30 November 2020 00:13 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/3 "2020-11-30T00:13:24Z")

</div>

Looking at [node-red source](https://github.com/node-red/node-red/blob/4bfe9a9ae90be502fac8892feb5c02fc13c4ad3b/packages/node_modules/%40node-red/nodes/core/network/31-tcpin.js#L234), server errors are sent without a 2nd parameter in the `node.send()` call so are not caught by the catch node.

This is just the way it is.

(IMHO) I wouldn't like to say if this is something that would or should change (at least not until a major version update) unless it is considered a bug.

NOTE. the 2nd parameter of node.send is normally the `msg` and since TCP IN doesn't have a msg, this might well be by design.

---

<div class="post-metadata">

### Author: ![garybia](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@garybia](https://discourse.nodered.org/u/garybia)
#### Post date: [30 November 2020 00:34 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/4 "2020-11-30T00:34:03Z")

</div>

yes I a looking at complete msg.

---

<div class="post-metadata">

### Author: ![garybia](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@garybia](https://discourse.nodered.org/u/garybia)
#### Post date: [30 November 2020 00:53 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/5 "2020-11-30T00:53:47Z")

</div>

I did look at the link to the source however I am not a good enough JS programmer to follow the code.  
IMHO ...  
Generally when I think of a catch then all errors should caught it should not be dependant on if something exists or not. I have in the past done a similar action using python, wait on tcp messages. The try catch there would trap this error. I obviously think it is a defect.

Anyways what I think I will do is setup a watchdog message that if it does not show up then I know the link is down and can handle the exception. Once I get the watchdog again then I can clean things up. Not ideal but good enough for this application.

BTW you guys are incredible on the support.

Thanks

---

<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: [29 January 2021 00:54 UTC](https://discourse.nodered.org/t/no-catch-of-tcp-timeout/36735/6 "2021-01-29T00:54:00Z")

</div>

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