ERROR: request ask for id= but got id= #2761
-
Hello. I have a couple of questions about this error message. I have a user of my project who is seeing these messages very frequently. In my environment, I have only ever seen these errors when there is a connection failure or communication issue. The application still seems to work as expected for them, but they are obviously concerned by the large number of errors they are seeing. I am certain that the requested device must be the correct id, as no-one else has reported this error. In this users environment, device ids 247, 1 and 2 would be used. This is an example log:
Any ideas? A related question is whether or not this message should be logged as an ERROR. It seems to be more like a WARNING. If it was a "real" error, I would expect to be able to catch it and examine the actual related request from my code perspective. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick response and explanation. |
Beta Was this translation helpful? Give feedback.
-
My theory is that the user has a network issue, and that the device is retrying to send the response. You can see that with the message with id 0x13 0x65. There is one send and then two recv messages, which I assume is the device retrying because of a network glitch. Message ids 0x13 0x69 and 0x13 0x7d are the same. Would it be possible to track the message ids and ignore any recv messages with a used id? |
Beta Was this translation helpful? Give feedback.
-
My apologies. It was my first time looking at the actual messages being exchanged, and I was confused by what I was seeing. Thank you for your explanantions. |
Beta Was this translation helpful? Give feedback.
-
What is the correct way to stop a message being processed when using a trace packet handler? def _trace_packet_handler(self, is_send: bool, packet: bytes) -> bytes:
if len(packet) < 2:
self._logger.warning(f"[TRACE] invalid packet: {packet.hex()}")
return packet
tid = int.from_bytes(packet[0:2], byteorder="big")
if is_send:
self._tid_tracker.add_expected(tid)
return packet
if self._tid_tracker.is_valid(tid):
self._tid_tracker.mark_processed(tid)
return packet
return b"" # is this correct? |
Beta Was this translation helpful? Give feedback.
As you can see in the log, you have a tcp/ip connection to the device.
The send contains id=1, but the device responds with id=2, that is wrong, but I cannot tell you why the device does that.
The message is discarded, and the next message is a correct response from id=1, so the app get a proper response.
Since the message is discarded this is clearly an ERROR and not a warning, in your case the normal response comes in the next message so discarding it do not have any consequences.
Pymodbus do provide tracepoints where the app can examine the incoming/outgoing message at byte stream level or at PDU level, so you are able to catch it.