Duplicate active TCP sockets generated by a single `Modbus_TCP_Slave`

More
5 days ago #420 by Eduardo
Environment Specs:
  • ProviewR Version: 6.1.5
  • OS: Linux (Debian 12 / Linux Mint)
  • Node / Bus: Development Node under Bus 999 (
    Code:
    plc_wicotas_0999_plc
    )
  • Modbus Gateway: Exemys EGW1 (Modbus TCP to RS-485 converter, IP
    Code:
    10.59.1.50:502
    )
  • Slave Devices: Micro Motion RFT9739 (Unit ID 1), Micro Motion 1700 MVD (Unit ID 3)
Issue Description:Upon starting the runtime process (
Code:
rt_ini &
) after a cold boot, the main PLC process (
Code:
plc_wicotas_0999_plc
) opens two simultaneous active TCP sockets to the Modbus gateway IP
Code:
10.59.1.50:502
. Both sockets actively transmit identical Modbus TCP request streams in parallel, causing frame collisions and delays on the underlying RS-485 serial bus.Diagnostic Evidence:1. Socket Inspection ( ss -tnp )
Code:
ESTAB 0 0 10.59.1.2:60178 10.59.1.50:502 users:(("plc_wicotas_0999_plc",pid=25050,fd=4)) ESTAB 0 24 10.59.1.2:60180 10.59.1.50:502 users:(("plc_wicotas_0999_plc",pid=25050,fd=6))
Both
Code:
Send-Q
and
Code:
Recv-Q
continuously fluctuate on both file descriptors (fd=4 and fd=6), proving that both sockets are actively exchanging traffic with the gateway (neither socket is idle or hanging).2. Payload Analysis ( tcpdump )Decoding the Modbus TCP application layer reveals a 1:1 mirror traffic pattern between local ports
Code:
60178
and
Code:
60180
:
  • Port 60178: Transmits
    Code:
    FC03
    (Read Holding Registers for PDU 246, 258, 244, 1) and
    Code:
    FC05
    (Write Single Coil 3) to Unit ID 1 and Unit ID 3.
  • Port 60180: Transmits identical
    Code:
    FC03
    and
    Code:
    FC05
    request bursts to Unit ID 1 and Unit ID 3 at the exact same intervals.
Verified Workbench Configuration:
  • There is strictly one Modbus_Master and one Modbus_TCP_Slave object under
    Code:
    wicoTAS ➔ IO
    .
  • A single
    Code:
    PlcThread
    (
    Code:
    Plc1
    ) is defined and assigned.
  • Attribute
    Code:
    Process = 1 (PLC)
    is set uniformly across all
    Code:
    Modbus_Module
    objects.
  • A clean build (
    Code:
    Clean Volume
    +
    Code:
    Build Node
    ) was performed, but two sockets continue to open automatically on runtime startup.
Questions for the Community / Developers:
  1. Why does the PLC runtime engine instantiate two independent TCP sockets (
    Code:
    fd=4
    and
    Code:
    fd=6
    ) for a single
    Code:
    Modbus_TCP_Slave
    object?
  2. Does ProviewR separate cyclic transactions (
    Code:
    Continuous = YES
    ) from triggered transactions (
    Code:
    Continuous = NO
    ) into dedicated sockets, or is
    Code:
    io_init()
    being called twice within the multithreaded framework?
  3. What is the recommended configuration to force ProviewR to multiplex all Modbus TCP requests over a single TCP socket descriptor?

Please Log in or Create an account to join the conversation.

More
4 days 23 hours ago #421 by Eduardo
Apologies for the formatting issue in the main post!** The forum editor automatically parsed the inline code tags into `Code:` blocks and split some lines, and I am unable to edit the original thread.

To summarize the core environment and issue cleanly:

**PLC Process:** `plc_wicotas_0999_plc` (Bus 999)
**Target Gateway:** Exemys EGW1 (`10.59.1.50:502`)
**Slaves:** Micro Motion RFT9739 (ID 1) & Model 1700 (ID 3)
**Issue:** Executing `rt_ini &` automatically opens two active TCP sockets (`fd=4` and `fd=6`) from the exact same process (`pid=25050`) to `10.59.1.50:502`, sending 1:1 identical Modbus TCP request bursts.

Thank you for your understanding and any guidance on how to resolve this duplicate socket behavior!

Please Log in or Create an account to join the conversation.

More
4 days 16 hours ago #422 by claes
Hi Eduardo,

I suspect you have configured two slave objects with the same IP address, and as every slave object will open a socket (which is normal for Modbus TCP slaves) there will be two sockets.

From ProviewR viewpoint there is only one TCP slave here, the modbus gateway, so you should only configure one slave object. Then use the UnitId in the module object to specify the target for each transaction.

All transactions, cyclic or triggered, are sent through the same socket.

/Claes

Please Log in or Create an account to join the conversation.

More
4 days 14 hours ago #423 by Eduardo
      Hi Claes,

Thanks a lot for the quick reply and the clarification!

I double-checked my I/O tree configuration in the Workbench to be 100% sure, and I can confirm that I only have a single Modbus_TCP_Slave object defined under `wicoTAS ➔ IO` configured with the gateway IP (`10.59.1.50`).
All `Modbus_Module` objects (for both Unit ID 1 and Unit ID 3) hang directly as children of this single slave object.

Despite having just one `Modbus_TCP_Slave` in the tree, as soon as `rt_ini` starts up, `ss -tnp` shows two active TCP sockets (fd=4 and fd=6) under the same PLC process PID (`plc_wicotas_0999_plc`), both sending 1:1 identical Modbus TCP frame bursts.

Could there be any hidden setting, cached runtime configuration, or thread initialization behavior that might cause the runtime to instantiate a second socket for the same slave object?

Thanks again for your support!

Best regards, Eduardo

Please Log in or Create an account to join the conversation.

Time to create page: 0.745 seconds
Powered by Kunena Forum