TCP Binding - can't get it to work properly


(Jonas) #1
  • Platform information:
    Raspberry Pi 3, latest java
    • openHAB version:
      OH 2.2
    • Items configuration related to the issue:
String WoZi_String_Temperatur "Wohnzimmertemperatur" {tcp="<[192.168.178.90:3000:'REGEX((.*))']"}
  • Services configuration related to the issue
port=3000
  • If logs where generated please post these here using code fences:
java.nio.channels.NotYetBoundException: null
	at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:237) [?:?]
	at org.openhab.binding.tcp.AbstractSocketChannelBinding.execute(AbstractSocketChannelBinding.java:1396) [251:org.openhab.binding.tcp:1.11.0]
	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [200:org.openhab.core.compat1x:2.2.0]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [200:org.openhab.core.compat1x:2.2.0]
2018-03-04 12:14:10.428 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread TCP Refresh Service

and since today:

2018-03-05 07:02:50.825 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:11654
2018-03-05 07:02:50.827 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:11654
2018-03-05 07:03:23.144 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:11558
2018-03-05 07:03:23.148 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:11558
2018-03-05 07:03:55.697 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:21847
2018-03-05 07:03:55.699 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:21847
2018-03-05 07:04:28.251 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:5379
2018-03-05 07:04:28.253 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:5379
2018-03-05 07:05:00.570 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:30474
2018-03-05 07:05:00.572 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:30474
2018-03-05 07:05:33.172 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:5211
2018-03-05 07:05:33.174 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:5211
2018-03-05 07:06:05.733 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:28281
2018-03-05 07:06:05.735 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:28281
2018-03-05 07:06:38.041 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.178.101:17006
2018-03-05 07:06:38.044 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.178.101:17006

I am trying to send some string data from an arduino (client).
One question (i tried both):
Do i have to set up a new ip adress for the server config (i think so) or do i have to use the one from my raspberry pi?
Is the server only confiugued in the items-file? i could not find a setting option in the .cfg-file.

Can you see, what i am doing wrong?

Thank you!


(Andy) #2

I’m having the same problem with OH1 and it’s really strange as sometimes I’m able to connect with Socat - TCP:IP:port and entered text is shown in the sitemap screen.

String  Zoneminder      "Zoneminder motion detected [%s]"       (gAlarm)        { tcp="<[192.168.2.225:*:'REGEX((.*))']" }
Group   item=gAlarm     label="Alarm"           icon="alarm"

It looks like it has something to do with the option addressmask. As soon as I change this setting (e.g. 127.0.0.1:*) openhab goes in an error loop with:

java.lang.NullPointerException: null
        at org.openhab.binding.tcp.AbstractSocketChannelBinding$Channel.<init>(AbstractSocketChannelBinding.java:139) ~[na:na]
        at org.openhab.binding.tcp.AbstractSocketChannelBinding.execute(AbstractSocketChannelBinding.java:1219) ~[na:na]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

(namraccr) #3

Please use code fences.


(Andy) #4

Updated with code fences.

I don’t know java but it looks like it’s going wrong in org.openhab.binding.tcp.AbstractSocketChannelBinding.java here:

                        logger.info(
                                "Received connection request from {}",
                                newChannel.getRemoteAddress());

                        Channel firstChannel = channels
                                .getFirstNotServed(Direction.IN,
                                        (InetSocketAddress) newChannel
                                                .getRemoteAddress());

                        if (firstChannel != null) {
.
.
.
                           } else {
                                logger.info(
                                        "Disconnecting the remote end {} that tries to connect an outbound only port",
                                        newChannel.getRemoteAddress());
                                newChannel.close();
                            }

How can I just ignore the port check?


(namraccr) #5

It seems this is not related to the original topic.
I suggest starting a new thread. You should include the tcp binding configuration you’re using.


[SOLVED] IDE errors
(Andy) #6

I’ve solved it after debugging with IDE :grinning:

Changed the IP address in the item to * and it worked immediatelly

String  Zoneminder      "Zoneminder motion detected [%s]"       (gAlarm)        { tcp="<[*:*:'REGEX((.*))']" }

(Andy) #7

Noted a second thing (haven’t counter checked the impact of my 1st solution), when you change something in openhab.cfg, openhab completely restarts. When you ‘only’ change an item, only the items are reloaded and the TCP plugin claims, “port is already in use”.
After a ‘real’ OH restart the TCP addon does work correctly.
So when I changed the plugin, OH was completely restarted. This may have been a reason it suddenly worked again.