diff --git a/pymodbus/transport/transport.py b/pymodbus/transport/transport.py index 34bd86a7b..7fa1a92d3 100644 --- a/pymodbus/transport/transport.py +++ b/pymodbus/transport/transport.py @@ -377,6 +377,7 @@ def send(self, data: bytes, addr: tuple | None = None) -> None: Log.error("Cancel send, because not connected!") return Log.debug("send: {}", data, ":hex") + self.recv_buffer = b"" if self.comm_params.handle_local_echo: self.sent_buffer += data if self.comm_params.comm_type == CommType.UDP: diff --git a/test/transport/test_comm.py b/test/transport/test_comm.py index 141b4c8d3..2639b3b99 100644 --- a/test/transport/test_comm.py +++ b/test/transport/test_comm.py @@ -242,7 +242,7 @@ async def test_connected_multiple(self, client, server, use_port): client2.send(test_data) await asyncio.sleep(0.5) - assert server2_connected.recv_buffer == test2_data + test_data + assert server2_connected.recv_buffer == test_data client2.close() server.close() await asyncio.sleep(0.5)