Trouble receiving tcp packets

Hi all,

I’m currently trying to receive a simple tcp packet using the tcp/udp binding but as you might guess I’m experiencing some problems. My PLC sends out a tcp packet containing some text in the data section which I want to ‘pump’ in an OpenHAB string item.

my item is as follows:

String TcpServer “Tcp server receive: [%s]” {tcp="<[*:‘REGEX((.))’]"}

when the PLC creates the connection and sends the data the connection is made as it should, yet the string item doesn’t get any content:

19:27:11.710 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - We will accept data coming from the remote end*
19:27:13.529 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /
19:27:13.529 [INFO ] [ing.tcp.AbstractSocketChannelBinding] -* is an allowed masked remote end. The channel will now be configured
19:27:14.045 [INFO ] [marthome.event.ItemStateChangedEvent] - TcpServer changed from NULL to null

To troubleshoot further I created a ‘debug’ rule:

rule “rule name”
Item TcpServer received update
logInfo(“TCP rule”, “content;” + TcpServer + “\n\n”)

Everytime the PLC sends data it get’s triggered which is good, the problem is that the state remains ‘null’:

19:29:52.493 [INFO ] [ipse.smarthome.model.script.TCP rule] - content;TcpServer (Type=StringItem, State=null, Label=Tcp server receive:, Category=null)

Wiresharking the session with the PLC I can find that the push packet looks as follows (data = ‘testing’):

My guess would be an issue with the conversion from bytes to string, yet I don’t really know how to troubleshoot this or even better resolve it.

Can anyone give any advice on how to resolve this?

Very much appreciated!

It appears you’re missing the port number and have the command in the wrong place.

tcp="<direction>[<command>:<ip address>:<port>:<transformationrule>]

your item:


Looks like it should be (but replace the ?? with the right port number):


I’m sorry namraccr but that makes no sense at all. As this is an incomming tcp connection the ‘’ value is not required, for the port I’m using the wildcard ‘*’. I’ve troubleshooted this further using packetsender and found that the issue lied with my regex expression.

this was the correct item definition:

String TcpServer “Tcp server receive: [%s]” {tcp="<['REGEX((.))’]"}

Thank you for your assistance.