Skip to content

Conversation

embedded-bed
Copy link
Contributor

When running a modbus server with the ignore_missing_devices flag set to True, the server will not send errors when clients request a wrong id (from the perspective of the server).

However, there's an error log before the flag check:

except NoSuchIdException:
    Log.error("requested device id does not exist: {}", self.last_pdu.dev_id)
    if self.server.ignore_missing_devices:
        return  # the client will simply timeout waiting for a response
    response = ExceptionResponse(self.last_pdu.function_code, ExcCodes.GATEWAY_NO_RESPONSE)

This error level log leads to a unexpected error spam in the pymodbus module.
To my understanding of this flag, the expected behavior would be for the requesthandler to ignore all packages that is not meant for the server id, which means this is not an error level logging case.

The PR moves the error log after the ignore_missing_devices check and adds a debug level log inside the if block.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@janiversen janiversen merged commit adc2019 into pymodbus-dev:dev Aug 26, 2025
1 check passed
@embedded-bed embedded-bed deleted the requesthandler_ignore_missing_devices_logging branch August 26, 2025 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants