Skip to content

Conversation

@Skyline-23
Copy link

This pull request introduces several reliability and usability improvements to the MRP protocol implementation, focusing on robust connection handling, improved command sending flexibility, and enhanced compatibility with sandboxed network environments. It also adds new tests to ensure correct behavior in these areas.

MRP Protocol Reliability and Command Handling:

  • Added robust connection checks and error handling in send and send_raw methods of MrpConnection, raising ConnectionLostError if the connection is closed or lost during send operations. [1] [2]
  • Refactored MrpProtocol to centralize connection state checks with _ensure_send_possible, ensuring proper exceptions are raised for invalid or closed states. Enhanced send and send_and_receive to handle fire-and-forget (no response) operations and propagate connection errors. [1] [2] [3]
  • Updated internal _send_command and public send_command in MrpRemoteControl to support fire-and-forget commands and custom timeouts, improving API flexibility. [1] [2] [3]

Network Compatibility Improvements:

  • Improved multicast socket setup and private address detection to work on sandboxed platforms (e.g., iOS, Docker) by probing the default IPv4 address as a fallback when no adapters are reported. [1] [2]

Testing Enhancements:

  • Added tests for fire-and-forget command sending, connection loss handling, and the new fallback network behaviors to ensure correctness and reliability. [1] [2] [3] [4]

@Skyline-23 Skyline-23 force-pushed the feat/fire-and-forget-remote branch from 13b792e to 873df66 Compare December 7, 2025 06:49
@Skyline-23
Copy link
Author

@postlund how about rebase this branch instead of merge main branch into feature branch?

@postlund
Copy link
Owner

@postlund how about rebase this branch instead of merge main branch into feature branch?

Yes, that would be great! I guess "Update" became a merge.

@Skyline-23 Skyline-23 force-pushed the feat/fire-and-forget-remote branch from cb8fd74 to a4b4acb Compare December 15, 2025 14:21
…rors

Add an opt-in fire-and-forget path for MRP remote commands while keeping defaults unchanged; allow overriding command timeouts. Treat closed transports during send as ConnectionLostError with an explicit reconnect hint and convert response timeouts to OperationTimeoutError. Cover the new behaviors in mrp protocol/interface tests.

# Conflicts:
#	pyatv/protocols/mrp/protocol.py
Add send_command entry point to RemoteControl interface and relay it via FacadeRemoteControl so consumers can use fire-and-forget/timeout overrides from supporting protocols.
@Skyline-23 Skyline-23 force-pushed the feat/fire-and-forget-remote branch from a4b4acb to ee56bfa Compare December 15, 2025 14:47
@Skyline-23
Copy link
Author

@postlund It's rebased, and it would be great if you consider my another PR

Copilot AI review requested due to automatic review settings January 21, 2026 17:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@postlund
Copy link
Owner

I like the robustness updates to MRP, but I feel that send_comnand is malplaced here. I believe we need to refine that concept more because exposing internals like that is sensitive. Can you remove that from the public API and work on that in a separate PR instead?

@Skyline-23
Copy link
Author

Addressed review: removed public send_command exposure from RemoteControl/facade/MRP API; internal _send_command remains for fire-and-forget usage. Updated MRP interface tests accordingly.

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.

2 participants