IngmarStein / tcp-multiplexer

Multiplexer over TCP. Allows multiple clients to use TCP servers with a limited number of concurrent connections.
MIT License
7 stars 1 forks source link

Can't get it to work #1

Open rucksman opened 1 month ago

rucksman commented 1 month ago

Trying to use it for a conntection to a solar inverter.

My command line: ./tcp-multiplexer server -p modbus -v -t <ip solar inverter>:<port solar inverter> -l 65008 Trying to connect to the server with a Windows client called QModMaster (https://sourceforge.net/projects/qmodmaster/files/). Connection seems to be successful as I can see both from the Windows Client and the output on the server.

Then I try to read a holding register. This is what I get on the server:

DEBU[2024-05-28T20:09:16Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:131 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).handleConnection() Message from client...
%s([]uint8) (len=12 cap=16) {
 00000000  00 01 00 00 00 06 01 03  90 8c 00 02              |............|
}

But the windows clent says: "Read data failed. System exception [Unknown error]". Sometimes the error is "Read data failed. Error: timeout".

If I connect directly to the inverter after stopping the tcp-multiplexer, I can see real data in the windows client. Any idea whats wrong here?

IngmarStein commented 1 month ago

The command line looks good and the request from the client reaches tcp-multiplexer. The request data appears to be a valid modbus message, too. Could you paste the remaining log? Anything about the connection from the multiplexer to the inverter?

rucksman commented 1 month ago

This is all I got. First the server CLI:

./tcp-multiplexer server -p modbus -v -t 10.10.0.225:502 -l 65008
INFO[2024-05-30T14:10:00Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:90 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).Start() #1: 10.10.0.210:56065 <-> 10.10.0.20:65008
INFO[2024-05-30T14:10:00Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:185 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).targetConnLoop() Connected clients: 1
DEBU[2024-05-30T14:10:09Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:131 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).handleConnection() Message from client...
%s([]uint8) (len=12 cap=16) {
 00000000  00 01 00 00 00 06 01 03  90 8b 00 02              |............|
}
INFO[2024-05-30T14:10:09Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:163 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).createTargetConn() creating target connection
INFO[2024-05-30T14:10:09Z]/home/runner/work/tcp-multiplexer/tcp-multiplexer/pkg/multiplexer/multiplexer.go:172 github.com/ingmarstein/tcp-multiplexer/pkg/multiplexer.(*Multiplexer).createTargetConn() new target connection: 10.10.0.20:34342 <-> 10.10.0.225:502

10.10.0.225 is the solar inverter, 10.10.0.210 is the Windows client, 10.10.0.20 the server running the tcp-mulitplexer.

Screenshot from the Windows Client: image

There is no log entry on the server. As you might see I did set the scan rate to five seconds, so every 5 seconds there is a new error in the windows client, but nothing on the server.

IngmarStein commented 1 month ago

At this point, tcp-multiplexer has successfully established a TCP connection to 10.10.0.225:502, but then seems to be hanging either when writing the client request to the inverter or when reading the response. If you're running the latest version, you should be getting timeouts after 60 seconds.

Did you check network connectivity between 10.10.0.20 and 10.10.0.225?

Can you provide the raw response corresponding to the 00 01 00 00 00 06 01 03 90 8c 00 02 request?

IngmarStein commented 3 weeks ago

Did you get it to work eventually?

rucksman commented 3 weeks ago

Unfortunately no, but I have to admit that I have very limited time to dig deeper into the problems these days. But I will definitely try again soon. Regarding your qestions about the response to the request: you can see all I get in my earlier post. There is no response, or at least no response that I can see.