Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.

feat: listen on Modbus port 502 by default (SIM-03) - #28

Merged
gavinying merged 2 commits into
v2from
default-port-502
Nov 10, 2026
Merged

gavinying merged 2 commits into
v2from
default-port-502

Conversation

@gavinying

Copy link
Copy Markdown
Collaborator

Summary

  • Default the listener to the standard Modbus ports: 502 for TCP and UDP, 802 for Modbus/TLS. A local simulator started with only --config is then reachable with modpoll --tcp 127.0.0.1, without --tcp-port.
  • When the operating system refuses the port, modsim exits before starting (exit code 2) and explains the two ways forward: rerun with sudo "$(command -v uvx)" … (plain sudo uvx usually cannot find uvx), or pass --port 5020 and point the client at it.
  • Managed deployments keep their explicit server.port; only the single-process CLI default changes.
  • README and the model configuration page document the default and the privilege rules.

Platform behavior

Platform Unprivileged bind to 127.0.0.1:502
Linux Refused (ip_unprivileged_port_start is 1024 by default); verified locally
macOS 10.14+ Allowed on 0.0.0.0; reports show binding only 127.0.0.1 still needs root
Windows Allowed; no privileged port range

Breaking change

modsim without --port now listens on 502 instead of 5020. Pass --port 5020 to keep the previous port. The ModioHub website keeps its commands on 5020 until this ships in a release, then drops --tcp-port from the local read command.

Tests

  • make check: lint, types and dependency checks pass.
  • make test: 114 passed, 2 skipped, including new tests for the 502 default, the privileged-port message, and a real non-root Linux bind to 502.
  • uv run --group docs mkdocs build -s passes.

Part of SIM-03 in the ModioHub master plan.

🤖 Generated with Claude Code

Default the listener to the standard Modbus port (502 for TCP and UDP,
802 for Modbus/TLS) so modpoll reaches a local simulator without
--tcp-port. When the operating system reserves the port, fail before
starting and explain how to rerun with sudo or pick a port above 1023.
Managed deployments keep their explicit server port.

BREAKING CHANGE: modsim without --port now listens on 502 instead of
5020; pass --port 5020 to keep the previous port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gavinying gavinying changed the title feat!: listen on Modbus port 502 by default (SIM-03) feat: listen on Modbus port 502 by default (SIM-03) Nov 10, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gavinying
gavinying merged commit 405c660 into v2 Nov 10, 2026
9 checks passed
@gavinying
gavinying deleted the default-port-502 branch November 10, 2026 08:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant