pymobiledevice3 icon indicating copy to clipboard operation
pymobiledevice3 copied to clipboard

AttributeError('__enter__') error when trying to use rsd address

Open morellexf13 opened this issue 1 year ago • 1 comments

Test environment

  • macOS Sonoma 14.4.1
  • iPhone XS iOS 17.5
  • pymobiledevice3 v4.5.3

Describe the bug Getting AttributeError('enter') error when trying to use rsd address

Issue Since asyncio refactor that cames with the wifi feature I'm getting AttributeError('enter') when trying to use rds address and dvt instance. While debugging: the name, peer_info, lock_down and all_values RemoteServiceDiscoveryService's attributes are somehow empty.

I can't figure out what could be happening here, this is a piece of code I had working until now where you can hopefully reproduce this.

def connection_context(self, callback):
  try:
      if Version(self.device_info.device_version) >= Version('17.0'):
          available_address = tunnel_creator.get_available_address() # {'address': 'fd6d:9665:5e8e::1', 'available': False, 'port': 64531}
          if available_address:
              with RemoteServiceDiscoveryService((available_address["address"], available_address["port"])) as rsd:
                  with DvtSecureSocketProxyService(rsd) as dvt:
                      callback(dvt)
          else:
              raise Exception("An error occurred getting tunnels addresses...")
      else:
          # Use USB Mux
          lockdown = self.get_lockdown()
          with DvtSecureSocketProxyService(lockdown=lockdown) as dvt:
              callback(dvt)
  except OSError:  # no route to host (Intel fix)
      pass
  except DeviceLockedError:
      raise
  except Exception as e:
      raise Exception(f"Connection not established... {e}")

morellexf13 avatar May 12 '24 11:05 morellexf13

That's because v4.0.0 changed the RSD API to be asyncio. See the release notes: https://github.com/doronz88/pymobiledevice3/releases/tag/v4.0.0

doronz88 avatar May 12 '24 14:05 doronz88

That's because v4.0.0 changed the RSD API to be asyncio. See the release notes: https://github.com/doronz88/pymobiledevice3/releases/tag/v4.0.0

Can I ask why is almost the entire project async now?

morellexf13 avatar May 13 '24 20:05 morellexf13

So tunneld won't get stuck when starting different tunnels simultaneously

doronz88 avatar May 13 '24 21:05 doronz88