How to get the ip of the client that is connected to the modbus server?

493 Views Asked by At

I am using ModbusTcpServer(context, identity=identity, address=(listener_address, listener_port)), here ModbusTcpServer is a function that is imported from pymodbus, I want to get the IP of client that get connected to the server for the logging purpose but unable to find a solution. It will be very helpful if someone can give a solution

1

There are 1 best solutions below

1
On

for connection_id in self.server.active_connections: connection=self.server.active_connections[connection_id] peername=connection.transport.get_extra_info("peername")