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=“<[192.168.1.16:*:‘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 192.168.1.16:*
19:27:13.529 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.1.16:35900
19:27:13.529 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - 192.168.1.16:* 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”
when
Item TcpServer received update
then
logInfo(“TCP rule”, “content;” + TcpServer + “\n\n”)
end

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:

tcp="<[192.168.1.16:*:‘REGEX((.))’]"

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

tcp="<[*:192.168.1.16:??:'REGEX((.*))']"

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=“<[192.168.1.16::'REGEX((.))']”}

Thank you for your assistance.