TCP Binding -- Connecting and Closing

I have a Gloobal Cache IP2IR that I’m using to control a TV and receiver.

The IP2IR takes simple ASCII commands on a specified port. I’m calling it with:
{ tcp=">[192.168.14.61:4998:MAP(denon.map)]" , autoupdate=“false”}

It seems that the default behavior of the TCP binding is to open a connection to the IP2IR and then leave it open. This caused problems when using multiple connections to the IP2IR that I was able to resolve in openhab.cfg with “tcp:bindingsharedconnections=false”.

However, after some time the IP2IR looks like it will close an unused connection. At this point, OpenHAB starts complaining.

I’m wondering if there’s a way to have the TCP connection not stay open (and not even open at startup), but instead simply open and close only when needed to issue a command. I don’t see anything in the binding configuration options on the wiki.

Thanks

I’m having a similar issue with my Aquos TV. I would love to find a way to close the connection when not needed. my openhab.log is filling with "is now connected " messages.

2017-05-01 22:59:39.858 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:40.200 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:40.513 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:40.824 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:41.136 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:41.390 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:41.702 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:42.013 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:42.325 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:42.637 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:42.950 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:43.262 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:43.573 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:43.885 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:44.197 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:44.508 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:44.820 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:45.176 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:45.488 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:45.799 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:46.111 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:46.429 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:46.740 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:47.052 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:47.364 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:47.675 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:47.987 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:48.298 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:48.610 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:48.922 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:49.233 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:49.547 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:49.859 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:50.200 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:50.511 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:50.827 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:51.139 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:51.450 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:51.762 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:52.073 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:52.386 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:52.701 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:53.013 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:53.325 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:53.638 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:53.952 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:54.265 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:54.518 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:54.830 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:55.183 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:55.501 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:55.812 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:56.123 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:56.435 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:56.746 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:56.999 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:57.313 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:57.625 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:57.938 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:58.249 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:58.561 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:58.872 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected
2017-05-01 22:59:59.184 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.2.134:10002 is now connected

Same problem here. I use the IRtrans binding (which also uses the TCP binding).

After a while, OpenHAB becomes unresponsive (CPU goes to 100%).

2017-05-16 11:01:46.267 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:46.539 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:46.793 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:47.048 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:47.288 [WARN ] [ding.irtrans.internal.IRtransBinding] - Did not receive an answer from the IRtrans device - Parsing is skipped
2017-05-16 11:01:47.301 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:47.542 [WARN ] [ding.irtrans.internal.IRtransBinding] - Did not receive an answer from the IRtrans device - Parsing is skipped
2017-05-16 11:01:47.554 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:47.807 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:48.060 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:48.290 [WARN ] [ding.irtrans.internal.IRtransBinding] - Did not receive an answer from the IRtrans device - Parsing is skipped
2017-05-16 11:01:48.313 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:48.544 [WARN ] [ding.irtrans.internal.IRtransBinding] - Did not receive an answer from the IRtrans device - Parsing is skipped
2017-05-16 11:01:48.566 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:48.819 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected
2017-05-16 11:01:49.072 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.3.14:21000 is now connected

Hello,
exactly the same problem.
If i disconnect my Arduino for short time and connect it again, no change. The log run exactly as in the previous comments. No change to stop the log messages which came nearly every second. After some time complete system hang.
If i shutdown and disconnect the RaspPi from power and start it new, then it will work as long as the receiver (Arduino) will never leave the network. If i disconnect the Arduino once and send only one message, the openHAB begins with the message that it is connect (it does’t matter if Arduino is connected or not).
I spent some days to solve that but i cant’t find a solution. Good to know that i’m not the only one with this problem. :slight_smile:
Also see here with the same issue:

Same issue also here:
https://groups.google.com/forum/#!topic/openhab/S-FINUEhhFc

Do i need a special config in tcp.cfg to avoid this behavior, or how do other users solve this behavior?
Pls help me, thx!!

Same problem here with OH2.3 at Xubuntu running the TCP binding “binding-tcp1 - 1.12.0.SNAPSHOT”. Everything is running fine, but after the network is lost shortly the binding floods the log and never reconnects. I left this message also at github page.

After a few days I noticed that my system got unresponsive - and yes this TCP binding problem slowly brings CPU load to 100% - I had to deactivate the TCP binding and restart OpenHAB2 …

My new solution to the unresponsive TCP binding is to not use it anymore. A solution is to use a pyhton script to translate TCP string to MQTT message. See my other post here.