pyatv icon indicating copy to clipboard operation
pyatv copied to clipboard

Reason for lost connection

Open postlund opened this issue 5 years ago • 1 comments

What feature would you like? Currently there's a callback method that is called when the connection is lost. There's however no way (programmatically) to know what happened. I feel that it would be good to provide that information.

Describe the solution you'd like My suggestion is to consolidate connection_closed and connection_lost into one method and add a reason parameter stating the reason why the connection was closed. The reasons I can come up with this far are:

  • Invoked by user (I.e. explicit call to close, same as connection_closed today)
  • Connection lost for arbitrary reason, e.g. timeout, reset, etc.
  • Heartbeat failure
  • Device goes to sleep (TheDeviceIsGoingToSleep error code in case of MRP)

This would effectively be a breaking change as it would require modifications to the DeviceListener interface. It can however be implemented to be non-breaking by calling the existing methods and mark them as deprecated for a while.

Any other information to share? No

postlund avatar Feb 22 '21 08:02 postlund

Also include which protocol that caused disconnect (when applicable).

postlund avatar Aug 26 '21 12:08 postlund