Skip to content

Conversation

@arrangabriel
Copy link

@arrangabriel arrangabriel commented Dec 11, 2025

Description

In my usage of your library I would like to continue sending requests to a server, even if one times out. Therefore I have added an option to the Modbux.Tcp.Client module that allows users to control whether the TCP connection should be closed when a timeout occurs in passive mode. The option close_on_timeout is set to true by default, so as to be backwards compatible.

Timeout handling logic:

  • Modified the timeout error handling in :confirmation so that the socket is only closed on timeout if close_on_timeout is set to true.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (the new option has been added to the documentation for the tcp client module)

How Has This Been Tested?

The change is very minor, albeit hard to test well. I have not added any tests for it.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Note

Adds close_on_timeout option (default true) to control whether the TCP socket is closed on passive-mode timeouts and updates timeout handling accordingly.

  • Modbus TCP Client (lib/tcp/client.ex)
    • Option: Introduces close_on_timeout (default true) in Client struct and init args to control socket closure on passive-mode timeouts.
    • Behavior: In :confirmation, only closes socket on :timeout when close_on_timeout is true; otherwise keeps connection open and resets cmd/msg state.
    • Docs: Updates module docs to document the new close_on_timeout option.

Written by Cursor Bugbot for commit c6f6b99. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@arrangabriel arrangabriel force-pushed the dont-close-tcp-connection-on-timeout branch from 2656efc to c6f6b99 Compare December 11, 2025 16:37
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