Skip to content

Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host #1337

@Mininggamer

Description

@Mininggamer

Python: 3.10
pymodbus: 3.1.3 (I still meet this issus when using version 2.5.3 with pymodbus.client.sync.ModbusTcpClient )
I'm trying to write data to my PLC through modbus tcp/ip. Here is my code:

from pymodbus.client import ModbusTcpClient

client = ModbusTcpClient("192.168.0.1", port = 502)
client.connect()

client.write_registers(0, 1)

It doesn't output anything. and my PLC doesn't receive any data.
If i use print(client.write_registers(0, 1)) instead of client.write_registers(0, 1) the terminal show

Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions