S
How to handle a invalid (protocol ID or PDU length) MBAP in Modbus TCP client response. What processing should be done by Modbus TCP client?
Options we have:
1. Should it close the connection.
If it should close the connection, what about the other messages the client has requested and waiting for response? Should we discard all transactions and give notification to application?
or any other suggestions.
2. If we need to discard only that transaction, we must first read the entire message from the link. But if the message length is more than 256 bytes then buffer overflow may happen.
If we put a condition and restrict to read the pdu, then in next iteration it reads the pdu first 7 bytes as MBAP header and continues till the message elapses. So this wastes our processing time and may even corrupt the next valid transactions.
So please suggest how to handle the invalid (protocol ID & PDU length) MBAP header response received on Modbus TCP client.
Options we have:
1. Should it close the connection.
If it should close the connection, what about the other messages the client has requested and waiting for response? Should we discard all transactions and give notification to application?
or any other suggestions.
2. If we need to discard only that transaction, we must first read the entire message from the link. But if the message length is more than 256 bytes then buffer overflow may happen.
If we put a condition and restrict to read the pdu, then in next iteration it reads the pdu first 7 bytes as MBAP header and continues till the message elapses. So this wastes our processing time and may even corrupt the next valid transactions.
So please suggest how to handle the invalid (protocol ID & PDU length) MBAP header response received on Modbus TCP client.