Skip to content

Test and hard delayed response test.#2636

Merged
janiversen merged 3 commits into
devfrom
delayed_response
Apr 13, 2025
Merged

Test and hard delayed response test.#2636
janiversen merged 3 commits into
devfrom
delayed_response

Conversation

@janiversen
Copy link
Copy Markdown
Collaborator

@janiversen janiversen commented Apr 13, 2025

A discussion in HomeAssistant detected un unreported issue, see home-assistant/core/138077

This PR focus on testing and harden the detection of delayed responses. The PR will be part of an upcoming v3.9.2

RTU Frames do not have any transaction ID, making it extra difficult to detect delayed responses, see the following examples

     Request 1:
        Response 1   # normal expected response

    Request 1:
        timeout
    Retry request 1:
        Response 1  # correct response to request
        Response retry 1  # discarded because there are no request

    Request 1:
         timeout
    Retry request 1:
         timeout, return to app
    Request 2:
         Response 1   # returned as wrong response
         Response 2. #  discarded because there are no request

The last example can only be avoided with a sufficiently large timeout !!!!

TCP/TLS Frames have a transaction ID, making it easy to detect delayed responses, see the following examples

     Request 1, tid 5:
        Response 1, tid 5  # normal expected response

    Request 1, tid 6:
        timeout
    Retry request 1, tid 6:
        Response 1, tid 6  # correct response to request
        Response retry 1, did 6  # discarded because there are no request

    Request 1, tid 7:
         timeout
    Retry request 1, tid 7:
         timeout, return to app
    Request 2, tid 8:
         Response 1 , tid 7  #   discarded because tid do not match
         Response 2, tid 8 # correct response to request

In general a timeout need to be sufficient large to e.g. allow a temporary dropout, typically 1-2 minutes. Please be aware that a large timeout, permits "good" requests to work efficiently, and only affects "bad" requests.

@janiversen janiversen merged commit 6d81ee3 into dev Apr 13, 2025
1 check passed
@janiversen janiversen deleted the delayed_response branch April 13, 2025 17:31
janiversen added a commit that referenced this pull request Apr 18, 2025
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.

1 participant