TCP - Unallowed remote end

Hey,

I was able to manage some TCP connections from my raspberry pi -python based programm to my OH2 Server on the same raspberry pi.

But there are some errors along the Inbound Connection from the python-based programm to the OH2 Server. The logfile says:

Received connection request from /127.0.0.1:56926
Disconnecting the unallowed remote end /127.0.0.1:56926
Received connection request from /127.0.0.1:56970
Disconnecting the unallowed remote end /127.0.0.1:56970

My TCP-Item looks like this:

String dummy "content: [%s]" { tcp="<[localhost:25001:'REGEX((.*))'], >[localhost:3001:'default']"}

And my tcp.cfg contains only:

port=25001

Is there a way to fix this issue?

And my Outbound connections works but it sends no string to my python-based programm. I thought I could send a String within the outbound connection with following rule:

rule myresponse
when
Item dummy changed
then
dummy.sendCommand("Hello back")
end

But the String “Hello back” is not sending to the python-based programm? Why?

Try using the IP address, not localhost. Do in this case use 127.0.0.1.

Also, the Python server is trying to connect to port 56926 and 56969, not port 25001. Since your item isn’t configured to listen on those ports OH rejects the connections.

It will only accept connections from localhost on port 25001.

If there is a fix for this, it will be in your python program.

I don’t think that it is the fault of my python program.
Since i wrote the port 25001 to the tcp.cfg and OH2 uses to be the server, OH2 will be bound on the port 25001. So my python program, as client, tries to connect to the server localhost:25001 with a dynamic port, except port 25001, because OH2 use already the port 25001 as server.

I tried to give the python client the port 25001 but it said that this port is already used. And as I mentioned, my python tcp client tries to connect with dynamic ports, so that is the reason why there a different ports in the log, like 56926 or 56969.

And because of that, i don’t really know how to fix this, because OH2 uses the port 25001 by itself but allow only clients on port 25001.

And that is the problem. OH can only accept connections on predefined ports and predefined IP addresses.

As configured, OH will only let localhost:25001 to connect to it. OH does not support dynamically selected ports.

I think the big disconnect here is that OH does not support two way sockets. You can either send a message to OH over a socket on a port or OH can send a message to some other server over a socket on a port. OH does not support two way traffic over the same port between itself and some other destination.

It has been ages since I’ve done anything with TCP directly (it is always worth the effort to use some higher level protocol) so I can’t be much help. All I know is that OH will only accept connections from localhost:25001 and will only send messages to localhost:3001 and to be successful you need to write your Python program accordingly.

It sounds like you are trying to cause your client to listen on port 25001 which isn’t allowed because OH is already listening on that port. Your python client needs to be listening on 3001 and publishing on 25001.