Can't get TCP Binding to send a simple word

I’ve just started playing with the TCP binding which I want it use to telnet into my Media Center PC, and then send the word “standby” to put it to sleep. This works however after a reboot of Openhab, it fills its logs with entries such as this

 2016-04-30 17:14:55.239 [INFO ] [t.AbstractSocketChannelBinding] - Attempting to reconnect the channel for /ipaddress:port
 2016-04-30 17:14:58.249 [WARN ] [t.AbstractSocketChannelBinding] - The channel java.nio.channels.SocketChannel[closed] has encountered an unknown IO Exception: No route to host

at 3 second intervals until I give in and turn the device its trying to connect to on. Is there a way of turning off the reconnection attempts or the logging? My item is

Switch MediaCenterPower { wol="ipaddress#mac-address",tcp=">[OFF:ipaddress:port:'MAP(MediaCenter.map)']" }

To calm the logging down I’ve changed the timeout from the default 3 seconds to 60 seconds, and also the retry interval to 10 minutes.

Is there a better way of sending this command or is there a way of turning off the reconnection feature until I send it a command?

UPDATE: The workaround didn’t go that well. When I turned the device off for the night the TCP binding started putting the following message in the log 4 times per second which eventually caused Openhab to run out of stack space and crash holding 37% of the memory and 97% of one of the CPU cores. It took around 2 hours after the repeat messages started to appear before other bindings started to fall apart, and eventually I got a lack of heap space message.

2016-04-30 23:59:56.991 [INFO ] [t.AbstractSocketChannelBinding] - The channel for /ipaddress:port is now connected

I’ve removed the TCP binding and I’m running expect-lite using “executeCommandLine” from a rule instead.
On Jessie I had to install “expect” before I could install “expect-lite”

Hi @kevin can you show us your example :grinning:
I also have problems with the tcp binding…
Regards
Jörg

I just used executeCommandline instead to call a linux command line
My rule is

rule "turn Media Center OFF"
when Item PercyOff changed from ON to OFF then
{	logInfo("LHP", "Media Center Turned OFF")
	executeCommandLine('"expect-lite" "-c" "/home/pi/MediaCenterStop.elt"', 2000)
	Thread::sleep(60000)
	sendCommand(PercyOff, ON)	}
end
1 Like